[Ubuntu] Setting up NIS for Ubuntu

2 minute read

NIS is very useful tool for automatic user information setup between clusters. Currently, my lab maintains four clusters: mark0, mark1, mark2 and mark3. Here, mark1 is working as NIS server where others are clients.

Note: If there is a group with root privilege in the server via sudo visudo, the group should be configured in clients also.

Server

Step 1. Update Ubuntu

$ apt-get update && apt-get -y dist-upgrade

Step 2. Install NIS

$ apt-get install -y rpcbind nis

...
NIS domain:
[DOMAIN NAME]

Note: We’ve set [DOMAIN NAME] as mark1.nis.

Step 3. Edit /etc/default/nis

$ sed -i 's/NISSERVER=.*$/NISSERVER=master/' /etc/default/nis

Step 4. Edit /etc/hosts

$ sudo vim /etc/hosts
...

[IP ADDRESS] [HOSTNAME]

Note: We’ve set it to 141.***.***.*** cglabmark1 where cglabmark1 is the host name of the server.

Step 5. Configure NIS

$ /usr/lib/yp/ypinit -m

At this point, we have to construct a list of the hosts which will run NIS
servers.
cglabmark1 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: cglabmark1
  next host to add: 
The current list of NIS servers looks like this:

  cglabmark1

Is this correct? [y/n: y] y
We need a few minutes to build the databases...
Building /var/yp/mark1.nis/ypservers...
Running /var/yp/Makefile...
gmake[1]: Entering directory '/var/yp/mark1.nis'
Updating passwd.byname...
...
gmake[1]: Leaving directory '/var/yp/mark1.nis'

cglabmark1 has been set up as a NIS master server.

Step 6. Update changes in user information

make -C /var/yp/

Client

Step 1. Update Ubuntu

$ apt-get update && apt-get -y dist-upgrade

Step 2. Install NIS

$ apt-get install -y rpcbind nis

Note

  • For step 2, make sure to add domain name of the server (For me, it is mark1.nis).
  • Domain name can be found at /etc/defaultdomain in the server.
  • We can change the domain name with $ dpkg-reconfigure nis.

Step 3. add following line to /etc/yp.conf

$ sudo vim /etc/yp.conf

domain mark1.nis server [IP ADDRESS of SERVER]

Note: Do not type domain address. NIS has a bug looking up DNS server.

Step 4. Edit /etc/nsswitch.conf

* option 1 (for ubuntu 18.04)

$ sudo sed -i 's/compat$/compat nis/g;s/dns$/dns nis/g' /etc/nsswitch.conf

* option 2

$ vim /etc/nsswitch.conf

passwd:     compat nis      # line 7; add
group:      compat nis      # add
shadow:     compat nis      # add

hosts:      files dns nis   # add

Step 5. Edit /etc/pam.d/common-session for creating home directory automatically

$ vim /etc/pam.d/common-session

# add to the end
session optional       pam_mkhomedir.so skel=/etc/skel umask=000

Step 6. Restart NIS

$ sudo systemctl restart rpcbind
$ sudo systemctl restart nis

Note: If an user sets up one’s default shell other than bash (e.g., zsh), make sure to install it!


For ubuntu18.04, we need to change systemd setting

comment out IPAdressDeny=Any in /lib/systemd/system/systemd-logind.service


References

How to install a cluster with NIS and NFS in Ubuntu 16.04
Configure NIS Server
Configure NIS Client
for ubuntu18.04


Leave a Comment