navigation
Home
admin
|
NIS
October 18th, 2016
|
| Tables des matières |  |
Présentation
Installation d'un serveur NIS sur Centos 6.3
Installation d'un client NIS sur Centos 6.4
Extraire des données des bases NIS
Installation d'un serveur NIS esclave (slave) sur Centos 6.4
Modifications des mots de passe
Automount
| Présentation |  |
"D'après Wikipedia (encyclopédie libre) : "Son but est de distribuer les informations contenues dans des fichiers de configuration contenant par exemple les noms d'hôte (/etc/hosts), les comptes utilisateurs (/etc/passwd), etc. sur un réseau.
Un serveur NIS stocke et distribue donc les informations administratives du réseau, qui se comporte ainsi comme un ensemble cohérent de comptes utilisateurs, groupes, machines, etc.
A l'origine, NIS est sorti sous le nom de « Yellow Pages » (YP) ou Pages jaunes mais le nom étant déposé par la compagnie anglaise British Telecom, Sun a renommé son protocole NIS. Cependant, les commandes NIS commencent toutes par yp. "
Sources :
http://doc.ubuntu-fr.org/nis
http://fr.wikipedia.org/wiki/Network_Information_Service
http://www.web-manual.net/linux-3/nis-configuration-on-centosrhel-linux/
Pour la gestion des répertoires des utilisateurs, il est intéressant d'installer un serveur NFS. L'installation d'un tel serveur est détaillée ici : ?doc=Serveur_NFS
| Installation d'un serveur NIS sur Centos 6.3 |  |
[root@serveur1 ~]# cat /etc/redhat-release
CentOS release 6.3 (Final) |
Recherche des paquets à installer
[root@serveur1 ~]# yum search nis |grep NIS
slapi-nis.i686 : NIS Server and Schema Compatibility plugins for Directory
ypbind.i686 : The NIS daemon which binds NIS clients to an NIS domain
ypserv.i686 : The NIS (Network Information Service) server
yp-tools.i686 : NIS (or YP) client programs |
Installation
[root@serveur1 ~]# yum install ypserv ypbind yp-tools
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.mirror.fr.planethoster.net
[...] |
Configuration du fichier /etc/sysconfig/network
[root@serveur1 ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=serveur1
NISDOMAIN=mynisdom.fr |
Lancement des services
[root@serveur1 ~]# service ypserv start
Setting NIS domain name mynisdom.fr: [ OK ]
Starting YP server services: [ OK ]
[root@serveur1 ~]# service yppasswdd start
Starting YP passwd service: [ OK ]
[root@serveur1 ~]# service ypxfrd start
Starting YP map server: [ OK ] |
The yppasswdd daemon is a server that receives and executes requests for new passwords from the yppasswd command.
Lancement des services au boot
[root@serveur1 ~]# chkconfig ypserv on
[root@serveur1 ~]# chkconfig yppasswdd on
[root@serveur1 ~]# chkconfig ypxfrd on |
Vérifications
[root@serveur1 ~]# chkconfig |grep yp
ypbind 0:arrêt 1:arrêt 2:arrêt 3:arrêt 4:arrêt 5:arrêt 6:arrêt
yppasswdd 0:arrêt 1:arrêt 2:marche 3:marche 4:marche 5:marche 6:arrêt
ypserv 0:arrêt 1:arrêt 2:marche 3:marche 4:marche 5:marche 6:arrêt
ypxfrd 0:arrêt 1:arrêt 2:marche 3:marche 4:marche 5:marche 6:arrêt |
Initialisation du serveur
[root@serveur1 ~]# /usr/lib/yp/ypinit -m
At this point, we have to construct a list of the hosts which will run NIS
servers. serveur1 is in the list of NIS server hosts. Please continue to add
the names for the other hosts, one per line. When you are done with the
list, type a <control D>.
next host to add: serveur1
next host to add:
The current list of NIS servers looks like this:
serveur1
Is this correct? [y/n: y]
We need a few minutes to build the databases...
Building /var/yp/mynisdom.fr/ypservers...
Running /var/yp/Makefile...
gmake[1]: entrant dans le répertoire « /var/yp/mynisdom.fr »
Updating passwd.byname...
Updating passwd.byuid...
Updating group.byname...
Updating group.bygid...
Updating hosts.byname...
Updating hosts.byaddr...
Updating rpc.byname...
Updating rpc.bynumber...
Updating services.byname...
Updating services.byservicename...
Updating netid.byname...
Updating protocols.bynumber...
Updating protocols.byname...
Updating mail.aliases...
gmake[1]: quittant le répertoire « /var/yp/mynisdom.fr »
serveur1 has been set up as a NIS master server.
Now you can run ypinit -s serveur1 on all slave server.
[root@serveur1 ~]# |
Création d'un utilisateur et mise à jour de la base NIS
Création d'un utilisateur
[root@serveur1 ~]# useradd u1
[root@serveur1 ~]# passwd u1
Changement de mot de passe pour l'utilisateur u1.
Nouveau mot de passe :
Retapez le nouveau mot de passe :
passwd : mise à jour réussie de tous les jetons d'authentification. |
Mise à jour de la base NIS
[root@serveur1 ~]# cd /var/yp
[root@serveur1 yp]# make
gmake[1]: entrant dans le répertoire « /var/yp/mynisdom.fr »
Updating passwd.byname...
Updating passwd.byuid...
Updating group.byname...
Updating group.bygid...
Updating netid.byname...
gmake[1]: quittant le répertoire « /var/yp/mynisdom.fr » |
ou
[root@serveur1 ~]# make -C /var/yp
[...] |
Mise à jour de l'esclave (s'il existe)
[root@dell2 ~]# /usr/lib/yp/ypxfr_1perday
Trying ypxfrd ... success
Trying ypxfrd ... success
Map on Master "serveur1" is not newer
ypxfr: Master's version not newer
Map on Master "serveur1" is not newer
ypxfr: Master's version not newer
ypxfr: Can't get master address
ypxfr: Can't get master address
Map on Master "serveur1" is not newer
ypxfr: Master's version not newer
Map on Master "serveur1" is not newer
ypxfr: Master's version not newer
Map on Master "serveur1" is not newer
ypxfr: Master's version not newer
Map on Master "serveur1" is not newer
ypxfr: Master's version not newer
[root@dell2 ~]# |
| Installation d'un client NIS sur Centos 6.4 |  |
[root@dell ~]# cat /etc/redhat-release
CentOS release 6.4 (Final) |
Installation
[root@dell ~]# yum install ypbind
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.atosworldline.com
[...] |
Configuration
[root@dell ~]# authconfig-tui
Démarrage de rpcbind : [ OK ]
Démarrage du service NIS : [ OK ]
Liaison du service NIS : . [ OK ] |
Les cases à cocher sont :
Use NIS
Use MD5 passwords # + secure
Use Shadow Passwords # les mots de passe sont stockés dans le fichier /etc/shadow
Local authorization is sufficient # les comptes locaux resteront accessibles
Les lignes du fichier /etc/shadow sont construites ainsi :
cryptage utilisé, salt, mot de passe crypté (séparés par le signe "$")
Le mot de passe peut être crypté en md5 (valeur $1$), sha256 (valeur $5$) ou sha512 (valeur $6$).
Fichiers modifiés
[root@dell ~]# cat /etc/yp.conf
domain mynisdom.fr server 192.168.1.90 |
[root@dell ~]# grep nis /etc/nsswitch.conf |egrep -v "^#|nisplus"
passwd: files nis
shadow: files nis
group: files nis
hosts: files nis dns
netgroup: files nis
automount: files nis |
[root@dell ~]# cat /etc/sysconfig/network
HOSTNAME=dell
NETWORKING=yes
NISDOMAIN=mynisdom.fr |
Mots de passe
"Users will now change their passwords using the NIS password command yppasswd instead of the local password file affected command, passwd. "
Vérifications
[root@dell ~]# ypwhich -m
mail.aliases serveur1
protocols.byname serveur1
group.bygid serveur1
rpc.bynumber serveur1
ypservers serveur1
services.byname serveur1
hosts.byaddr serveur1
passwd.byuid serveur1
services.byservicename serveur1
passwd.byname serveur1
hosts.byname serveur1
protocols.bynumber serveur1
group.byname serveur1
netid.byname serveur1
rpc.byname serveur1 |
Listes des tables
[root@dell2 ~]# ypcat passwd.byname
bruno:$6$1m23./An$OuKShwJWVU6q1qLrv4OuqfNrATB/estYwfWKgsIY4KRkjNZ8mZHLNBCBIJAFw0MMjY7MiMHYHR8CgePjOld260:500:500::/home/bruno:/bin/bash
u5:$6$f/HtyEUIO7LD/Olr$eQsTxyeaMARbW6ixwJ7JXnj.1yUZ7WvHTH0JhObznPncKgWr/hZH2EeS0q4vjtSGXAgP.KF7bG61/Fnny1MzK/:502:502::/home/user5:/bin/bash
u1:$6$XbBS1AWyCndOXCEf$mChxc.Y1b2.N6ltCZ8PlT0S0fDJULGGvcH0L3zWuNnZ5LHV7jXG.RUxWvNxd/R0NSt1qBnE6GCLtgZHaSpVAK1:501:501::/home/u1:/bin/bash |
| Extraire des données des bases NIS |  |
Source : http://www.yolinux.com/TUTORIALS/NIS.html
Construction d'un fichier passwd
Solution 1
[root@serveur1 ~]# /usr/lib/yp/makedbm -u /var/yp/mynisdom.fr/passwd.byname | awk -F: '!/YP/ {split($1,userid," ");print userid[1] ":x:" $3 ":" $4 ":" $5 ":" $6 ":" $7}'
bruno:x:500:500::/home/bruno:/bin/bash
u5:x:502:502::/home/user5:/bin/bash
u1:x:501:501::/home/u1:/bin/bash |
Solution 2
[root@dell ~]# ypcat passwd |awk -F: '{print $1":x:"$3":"$4"::"$6":"$7}'
bruno:x:500:500::/home/bruno:/bin/bash
u5:x:502:502::/home/user5:/bin/bash
u1:x:501:501::/home/u1:/bin/bash |
Construction d'un fichier shadow
Solution 1
[root@serveur1 ~]# /usr/lib/yp/makedbm -u /var/yp/mynisdom.fr/passwd.byname | awk -F: '!/YP/ {split($1,userid," ");print userid[1] ":" $2 ":13539:0:99999:7:::"}'
bruno:$6$1m23./An$OuKShwJWVU6q1qLrv4OuqfNrATB/estYwfWKgsIY4KRkjNZ8mZHLNBCBIJAFw0MMjY7MiMHYHR8CgePjOld260:13539:0:99999:7:::
u5:$6$f/HtyEUIO7LD/Olr$eQsTxyeaMARbW6ixwJ7JXnj.1yUZ7WvHTH0JhObznPncKgWr/hZH2EeS0q4vjtSGXAgP.KF7bG61/Fnny1MzK/:13539:0:99999:7:::
u1:$6$LHu8PtGc$Ti09ZKDb9PUy.N1xFUTlBAauQb.Lnmn9UcRKzUUYZ9XFmN5WOqZmpSChm92TGN9Bx6955mWusubyY9LQjjCxQ.:13539:0:99999:7::: |
Solution 2
[root@dell ~]# ypcat passwd |awk -F: '{print $1":"$2"::13539:0:99999:7:::"}'
bruno:$6$1m23./An$OuKShwJWVU6q1qLrv4OuqfNrATB/estYwfWKgsIY4KRkjNZ8mZHLNBCBIJAFw0MMjY7MiMHYHR8CgePjOld260:13539:0:99999:7:::
u5:$6$f/HtyEUIO7LD/Olr$eQsTxyeaMARbW6ixwJ7JXnj.1yUZ7WvHTH0JhObznPncKgWr/hZH2EeS0q4vjtSGXAgP.KF7bG61/Fnny1MzK/:13539:0:99999:7:::
u1:$6$LHu8PtGc$Ti09ZKDb9PUy.N1xFUTlBAauQb.Lnmn9UcRKzUUYZ9XFmN5WOqZmpSChm92TGN9Bx6955mWusubyY9LQjjCxQ.:13539:0:99999:7::: |
les requêtes 1 se font à partir du serveur. Les requêtes 2 se font sur le client.
Extraire des données sur un compte particulier
Sur le serveur
[root@serveur1 ~]# /usr/lib/yp/makedbm -u /var/yp/mynisdom.fr/passwd.byname | grep bruno
bruno bruno:$6$1m23./An$OuKShwJWVU6q1qLrv4OuqfNrATB/estYwfWKgsIY4KRkjNZ8mZHLNBCBIJAFw0MMjY7MiMHYHR8CgePjOld260:500:500::/home/bruno:/bin/bash |
Sur le client
[root@dell ~]# ypmatch bruno passwd
bruno:$6$1m23./An$OuKShwJWVU6q1qLrv4OuqfNrATB/estYwfWKgsIY4KRkjNZ8mZHLNBCBIJAFw0MMjY7MiMHYHR8CgePjOld260:500:500::/home/bruno:/bin/bash |
[root@dell ~]# ypcat passwd |grep bruno
bruno:$6$1m23./An$OuKShwJWVU6q1qLrv4OuqfNrATB/estYwfWKgsIY4KRkjNZ8mZHLNBCBIJAFw0MMjY7MiMHYHR8CgePjOld260:500:500::/home/bruno:/bin/bash |
[root@dell ~]# getent passwd bruno
bruno:$6$1m23./An$OuKShwJWVU6q1qLrv4OuqfNrATB/estYwfWKgsIY4KRkjNZ8mZHLNBCBIJAFw0MMjY7MiMHYHR8CgePjOld260:500:500::/home/bruno:/bin/bash |
| Installation d'un serveur NIS esclave (slave) sur Centos 6.4 |  |
Il est nécessaire de configurer au préalable le serveur NIS esclave comme un client NIS (cf. ci-dessus)
(on a des erreurs avec ypxfrd sinon)
Modification du fichier /etc/yp.conf : on indique que le serveur NIS sera local
[root@dell2 ~]# grep -v '^#' /etc/yp.conf
domain mynisdom.fr server dell2 |
Installation des paquets
[root@serveur1 ~]# yum install ypserv
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.mirror.fr.planethoster.net
[...] |
Démarrage des services NIS
service ypserv start
service yppasswdd start
service ypxfrd start |
Initialisation de l'esclave
/usr/lib/yp/ypinit -s <adresse IP du maitre> |
Modification de la config des clients
[root@dell ~]# grep -v '^#' /etc/yp.conf
domain mynisdom.fr server 192.168.1.90
domain mynisdom.fr broadcast |
Mise à jour des maps entre le serveur et le slave
Sur l'esclave :
[root@nisslave yp]# vi /etc/cron.d/nis_sync
#
# File: /etc/cron.d/nis_sync
#
20 * * * * /usr/lib/yp/ypxfr_1perhour
40 6 * * * /usr/lib/yp/ypxfr_1perday
55 6,18 * * * /usr/lib/yp/ypxfr_2perday
[root@nisslave yp]# service crond restart |
Source : www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch30_:_Configuring_NISa#NIS_Slave_Servers
Exemple de fichier maison :
[root@dell2 ~]# cat /usr/lib/yp/ypxfr_bruno
#! /bin/sh
#
YPBINDIR=/usr/lib/yp
MAPS_TO_GET=" passwd.byname passwd.byuid group.byname group.bygid hosts.byname hosts.byaddr rpc.byname rpc.bynumber services.byname services.byservicename netid.byname protocols.bynumber protocols.byname mail.aliases auto.master auto.home"
for map in $MAPS_TO_GET
do
$YPBINDIR/ypxfr -f -h serveur1 $map
done
[root@dell2 ~]# |
on notera dans l'exemple ci-dessus qu'on force la mise à jour ("-f") et qu'on définit explicitement le serveur sur lequel se fait la maj ("-h").
Tests...
| Modifications des mots de passe |  |
Les mots de passe se modifient par l'intermédiaire du daemon yppasswdd.
Celui-ci s'appuie sur ypbind => pour pouvoir modifier un mot de passe sur un serveur, celui-ci doit être client NIS.
yppasswd contacte le master pour le prévenir de la modification.
Pour que les esclaves prennent en compte cette modification il faut relancer les maj des tables via ypxfrd.
| Automount |  |
Avant d'essayer de faire fonctionner l'autofs via les tables de nis, il peut être judicieux de le faire fonctionner classiquement.
cf http://perso.univ-lemans.fr/~brichard/logiciels/?doc=autofs
Une fois ces tests effectués, sur le master nis,
Modifiez le fichier /etc/auto.master :
[root@serveur1 ~]# cat /etc/auto.master
/home auto.home |
Modifiez le fichier /etc/auto.home :
[root@serveur1 ~]# cat /etc/auto.home
* -fstype=nfs,soft,intr 192.168.1.90:/home/& |
puis intégrez, les fichiers aux tables nis :
[root@serveur1 ~]# make -C /var/yp
make: entrant dans le répertoire « /var/yp »
gmake[1]: entrant dans le répertoire « /var/yp/mynisdom.fr »
Updating passwd.byname...
Updating passwd.byuid...
Updating group.byname...
Updating group.bygid...
Updating hosts.byname...
Updating hosts.byaddr...
Updating rpc.byname...
Updating rpc.bynumber...
Updating services.byname...
Updating services.byservicename...
Updating netid.byname...
Updating protocols.bynumber...
Updating protocols.byname...
Updating mail.aliases...
Updating auto.master...
Updating auto.home...
# netgrp shadow publickey networks ethers bootparams printcap
# amd.home auto.master auto.home auto.local passwd.adjunct
# timezone locale netmasks
gmake[1]: quittant le répertoire « /var/yp/mynisdom.fr »
make: quittant le répertoire « /var/yp »
[root@serveur1 ~]# |
Il ne faut pas oublier de modifier le fichier /var/yp/Makefile pour que toutes les tables soient prises en compte :
[root@serveur1 ~]# cat /var/yp/Makefile
[...]
# If you don't want some of these maps built, feel free to comment
# them out from this list.
all: passwd group hosts rpc services netid protocols mail
auto.master auto.home
# netgrp shadow publickey networks ethers bootparams printcap
# amd.home auto.master auto.home auto.local passwd.adjunct
# timezone locale netmasks
[...] |
Sur le client il faut que dans le fichier nsswitch.conf l'automount pointe bien vers nis :
[root@dell ~]# more /etc/nsswitch.conf
#
[...]
automount: files nis
aliases: files nisplus
[root@dell ~]# |
Source : http://krolm.blogspot.fr/2012/09/nis-nfs-automounter.html
|
|
Dernières modifs
|
|---|
VNC (November 22nd, 2020) Editeurs (October 20th, 2016) Awk (October 18th, 2016) Claws Mail (October 18th, 2016) Cups (October 18th, 2016) Gimp (October 18th, 2016) Git (October 18th, 2016) |
Contact
|
|---|
Pour m'envoyer un mail, Pour me laisser un commentaire :richard.brunooo chez gmail.com |  |
|
|