NIS configuration not working on Linux - TechRepublic
Question
March 24, 2009 at 08:02 AM
rajaraman_swaminathan

NIS configuration not working on Linux

by rajaraman_swaminathan . Updated 17 years, 3 months ago

NFS Server

1. Edit the /etc/exports file to allow NFS mounts of the /home directory with
read/write access.

/home * (rw,sync,no_root_squash)

2. Let NFS read the /etc/exports file for the new entry, and make /home
available to the network with the exportfs command.

[root@FEDORA ~]#exportfs -a

3. Make sure the required nfs, nfslock, and portmap daemons are both running
and configured to start after the next reboot.

[root@FEDORA ~]# chkconfig nfslock on
[root@FEDORA ~]# chkconfig nfs on
[root@FEDORA ~]# chkconfig portmap on
[root@FEDORA ~]# service portmap start
Starting portmapper: [ OK ]
[root@FEDORA ~]# service nfslock start
Starting NFS statd: [ OK ]
[root@FEDORA ~]# service nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]
[root@FEDORA ~]#

The above services were started successfully. But after starting nfs service
it gave some warnings – ‘incompatible duplicated export entries’

NFS Client

1. Make sure the required netfs, nfslock, and portmap daemons are running and
configured to start after the next reboot.

[root@A4MD09479 ~]# chkconfig nfslock on
[root@A4MD09479 ~]# chkconfig netfs on
[root@A4MD09479 ~]# chkconfig portmap on
[root@A4MD09479 ~]# service portmap start
Starting portmapper: [ OK ]
[root@A4MD09479 ~]# service netfs start
Mounting other filesystems: [ OK ]
[root@A4MD09479 ~]# service nfslock start
Starting NFS statd: [ OK ]
[root@A4MD09479 ~]#

All services except netfs were started successfully.netfs could not be started

2. Make sure you can mount FEDORA’s /home directory on the new /home directory
you just created. Unmount it once everything looks correct.

[root@A4MD09479 ~]# mount 172.22.45.16:/home /home/
[root@A4MD09479 ~]# ls /home
harish nisuser oneadmin test test1
[root@A4MD09479 ~]# umount /home

3. Start configuring autofs automounting. Edit your /etc/auto.master file to
refer to file /etc/auto.home for mounting information whenever the /home
directory is accessed. After five minutes, autofs unmounts the directory.

#/etc/auto.master
/home /etc/auto.home –timeout 600

These details were actually commented in the auto.master file

4. Edit file /etc/auto.home to do the NFS mount whenever the /home directory
is accessed. If the line is too long to view on your screen, you can add a \
character at the end to continue on the next line.

#/etc/auto.home
* -fstype=nfs,soft,intr,rsize=8192,wsize=8192,nosuid,tcp \
192.168.1.100:/home/&

There is no auto.home file. Instead the auto.misc file had these details
commented.

5. Start autofs and make sure it starts after the next reboot with the
chkconfig command.

[root@A4MD09479 ~]# chkconfig autofs on
[root@A4MD09479 ~]# service autofs restart
Stopping automount:[ OK ]
Starting automount:[ OK ]
[root@A4MD09479 ~]#

autofs start was successful

NIS Server

1. #/etc/sysconfig/network
NISDOMAIN=MTWP3NIS.COM

2. NIS servers also have to be NIS clients themselves, so you’ll have to edit
the NIS client configuration file /etc/yp.conf to list the domain’s NIS server
as being the server itself or localhost.

# /etc/yp.conf – ypbind configuration file
ypserver 127.0.0.1

This entry is commented. Instead the following entry is present

domain MTWP3NIS.COM server 172.22.45.16

3. Start the necessary NIS daemons in the /etc/init.d directory and use the
chkconfig command to ensure they start after the next reboot.

[root@FEDORA ~]# service portmap start
Starting portmapper: [ OK ]
[root@FEDORA ~]# service yppasswdd start
Starting YP passwd service: [ OK ]
[root@FEDORA ~]# service ypserv start
Setting NIS domain name NIS-SCHOOL-NETWORK: [ OK ]
Starting YP server services: [ OK ]
[root@FEDORA ~]#

[root@FEDORA ~]# chkconfig portmap on
[root@FEDORA ~]# chkconfig yppasswdd on
[root@FEDORA ~]# chkconfig ypserv on

All services were started successfully

4. Make sure they are all running before continuing to the next step. You can
use the rpcinfo command to do this.

[root@FEDORA ~]# rpcinfo -p localhost
program vers proto port
100000 2 tcp 111 portmapper
100000 2 udp 111 portmapper
100009 1 udp 681 yppasswdd
100004 2 udp 698 ypserv
100004 1 udp 698 ypserv
100004 2 tcp 701 ypserv
100004 1 tcp 701 ypserv
[root@FEDORA ~]#

All above 3 services including ypbind, ypxfrd, nlockmgr, nfs were present in
the above list.

5. Initialize Your NIS Domain

[root@FEDORA ~]# /usr/lib/yp/ypinit -m
At this point, we have to construct a list of the hosts which will run NIS
servers. bigboy 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 .
next host to add: FEDORA.MINDTREE.COM
next host to add:
The current list of NIS servers looks like this:

FEDORA.MINDTREE.COM

Is this correct? [y/n: y] y
We need a few minutes to build the databases…
Building /var/yp/MTWP3NIS.COM/ypservers…
Running /var/yp/Makefile…
gmake[1]: Entering directory `/var/yp/MTWP3NIS.COM’
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]: Leaving directory `/var/yp/MTWP3NIS.COM’

FEDORA.MINDTREE.COM has been set up as a NIS master server.

Now you can run ypinit -s bigboy on all slave server.
[root@FEDORA ~]#

The command ran successfully as shown above.

6. You can now start the ypbind and the ypxfrd daemons because the NIS domain
files have been created.

[root@FEDORA ~]# service ypbind start
Binding to the NIS domain: [ OK ]
Listening for an NIS domain server.
[root@FEDORA ~]# service ypxfrd start
Starting YP map server: [ OK ]
[root@FEDORA ~]# chkconfig ypbind on
[root@FEDORA ~]# chkconfig ypxfrd on

Both the services were successfully restarted

7. Adding new NIS users

[root@FEDORA ~]# useradd -g users nisuser
[root@FEDORA ~]# passwd nisuser
Changing password for user nisuser.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@FEDORA ~]# cd /var/yp
[root@bigboy yp]# make
gmake[1]: Entering directory `/var/yp/NIS-SCHOOL-NETWORK’
Updating passwd.byname…
Updating passwd.byuid…
Updating netid.byname…
gmake[1]: Leaving directory `/var/yp/NIS-SCHOOL-NETWORK’
[root@FEDORA yp]#

8. You can check to see if the user’s authentication information has been
updated by using the ypmatch command, which should return the user’s encrypted
password string.

[root@FEDORA yp]# ypmatch nisuser passwd
nisuser:$1$d6E2i79Q$wp3Eo0Qw9nFD/::504:100::/home/nisuser:/bin/bash
[root@FEDORA yp]

You can also use the getent command, which has similar syntax. Unlike ypmatch,
getent doesn’t provide an encrypted password when run on an NIS server, it
just provides the user’s entry in the /etc/passwd file. On a NIS client, the
results are identical with both showing the encrypted password.

[root@FEDORA yp]# getent passwd nisuser
nisuser:x:507:100::/home/nisuser:/bin/bash
[root@FEDORA yp]#

Both commands worked successfully

NIS Client

1. The authconfig or the authconfig-tui program automatically configures your
NIS files after prompting you for the IP address and domain of the NIS server.

[root@A4MD09479 ~]# authconfig-tui

2. Once finished, it should create an /etc/yp.conf file that defines, amongst
other things, the IP address of the NIS server for a particular domain. It
also edits the /etc/sysconfig/network file to define the NIS domain to which
the NIS client belongs.

# /etc/yp.conf – ypbind configuration file
domain MTWP3NIS.COM server 172.22.45.16

#/etc/sysconfig/network
NISDOMAIN=MTWP3NIS.COM

The above 2 entries are updated

3. In addition, the authconfig program updates the /etc/nsswitch.conf file that
lists the order in which certain data sources should be searched for name
lookups, such as those in DNS, LDAP, and NIS. Here you can see where NIS
entries were added for the important login files.

#/etc/nsswitch.conf
passwd: files nis
shadow: files nis
group: files nis

These entries are updated successfully

4. Start the ypbind NIS client, and portmap daemons in the /etc/init.d
directory and use the chkconfig command to ensure they start after the next
reboot. Remember to use the rpcinfo command to ensure they are running
correctly.

[root@A4MD09479 ~]# service portmap start
Starting portmapper: [ OK ]
[root@A4MD09479 ~]# service ypbind start
Binding to the NIS domain:
Listening for an NIS domain server.
[root@A4MD09479 ~]#

[root@A4MD09479 ~]# chkconfig ypbind on
[root@A4MD09479 ~]# chkconfig portmap on

These 2 services were started successfully

5. Verify Name Resolution

#
# File: /etc/hosts (A4MD09479)
#
172.22.45.16 FEDORA.MINDTREE.COM

#
# File: /etc/hosts (FEDORA)
#
172.22.45.156 A4MD09479.MINDTREE.COM

Both files are correctly updated

6. You can run the ypcat, ypmatch, and getent commands to make sure
communication to the server is correct.

[root@A4MD09479 ~]# ypcat passwd
nisuser:$1$Cs2GMe6r$1hohkyG7ALrDLjH1:505:100::/home/nisuser:/bin/bash
[root@A4MD09479 ~]#

[root@A4MD09479 ~]# ypmatch nisuser passwd
nisuser:$1$d6E2i79Q$wp3Eo0Qw9nFD/:504:100::/home/nisuser:/bin/bash
[root@A4MD09479 ~]#

[root@A4MD09479 ~]# getent passwd nisuser
nisuser:$1$d6E2i79Q$wp3Eo0Qw9nFD/:504:100::/home/nisuser:/bin/bash
[root@A4MD09479 ~]#

All commands ran successfully

7. Try logging into the NIS client via SSH.

[root@FEDORA ~]# ssh -l nisuser 172.22.45.156
nisuser@172.22.45.156’s password:
[nisuser@A4MD09479 nisuser]$

This does not work. It gives a ‘Permission denied’ message and does not login
via ssh.

Please let me know how i can successfully ssh to the NIS client. I am newbie to NIS.

This discussion is locked

All Comments