Setting Up NIS and autofs

Updated 2013 here

0. If you change anything (add a user, etc.), make sure to do:
sudo make -C /var/yp
1. Add server to /etc/hosts. This means that you can still find the server if there is a DNS failure.
2. Install the software you need
sudo apt-get install portmap nis autofs nfs-common
You will be asked for the name of your NIS domain. Enter the name of your NIS domain. If you entered wrongly or want to change the defaultdomain of NIS change it in the file /etc/defaultdomain
For example, robotics is the name of my NIS server. Remember this parameter is case sensitive. It is probably a good idea to then add a portmap line to /etc/hosts.allow for security reasons:
portmap : <NIS server IP address>
Where "NIS server IP address" is the IP address of the NIS server.
3. Set up name services to use NIS:
Edit /etc/passwd to add a line at the end saying:
Edit /etc/group to add a line at the end saying:
Edit /etc/shadow to add a line at the end saying:
This sets up those services to include NIS entries if a match isn't found in the file. You could change other services to use NIS by using the NIS service in /etc/nsswitch.conf, but these are the important ones.
4. Edit /etc/yp.conf and add the line:
ypserver ypserver 987.65.43.21
Where and 987.65.43.21 are the NIS servers.
5. Restart NIS:
/etc/init.d/nis restart
Note: sshd will need to be restarted to use the new authentication system. Just an FYI.
Note: A frequently asked question is how to give NIS users audio, DRI, video privileges. Simply add the user's group to video in file /etc/group
6. If you are using autofs with NIS you need this file nsswitch.conf  in ubuntu:
# /etc/nsswitch.conf
# An example Name Service Switch config file. This file should be
# sorted with the most-used services at the beginning.
# The entry '[NOTFOUND=return]' means that the search for an
# entry should stop if the search in the previous entry turned
# up nothing. Note that if the search failed due to some other reason
# (like no NIS server responding) then the search continues with the
# next entry.
# Legal entries are:
#       compat                  Use compatibility setup
#       nisplus                 Use NIS+ (NIS version 3)
#       nis                     Use NIS (NIS version 2), also called YP
#       dns                     Use DNS (Domain Name Service)
#       files                   Use the local files
#       [NOTFOUND=return]       Stop searching if not found so far
# For more information, please read the  nsswitch.conf.5 manual page.

# passwd: files nis
# shadow: files nis
# group:  files nis

passwd: compat
group:  compat

hosts:  files dns
networks:       files dns

services:       files nis
protocols:      files
rpc:    files
ethers: files
netmasks:       files
netgroup:       files nis
publickey:      files

bootparams:     files
automount:      files nis
aliases:        files nis
shadow: compat

If you get an error likestartkde: kpersonalizer not found! Please install to properly configure your user.
 This means problem with normal user accessing video. Add the user to group "video" (/etc/group).