Users & Groups - NIS

If you use several computers connected on a network, it can become a hassle to keep track of the usernames and passwords you use to access each machine. NIS (Network Information Service) lets you to keep a centralised database of usernames and passwords on a server so you can use the same username and password on each machine on the network.

In a home situation, this would mean all members of your family would be able to log in to any computer with the same username and password. This month's Linux Here's How will show you how to set up an NIS server under Linux to provide username and password authentication for a network of Linux/UNIX computers.

The NIS service is based on the client-server model. To use NIS on your network you need a single NIS server to which the other computers on your network connect using an NIS client. The NIS server stores the user database, which is mirrored on each of the clients.

NIS uses the concept of domains to organise the computers on your network. All computers in a domain access the same user and password database. In this column we will call our domain 'home' and make all of the computers on the network members of the domain.

For more information on NIS and the Linux implementation of the protocol, see www.linux-nis.org

Setting up the server

You do not need a powerful computer to run an NIS server, but you will need a computer that is switched on all the time so that the other computers on your network can access it.

Most Linux distributions include a copy of the Linux NIS server. The package will be named 'ypserv'. There was a copy of the latest version of ypserv on May's cover CD, but, if available, you should install the version provided with your distribution.

After installing ypserv from your distribution or the cover CD, create the directory /var/yp by typing in a shell as root:

$ mkdir /var/yp

Ypserv reads from a configuration file specifying the domains available and the networks connected to each. To create the configuration file, enter the following in a text editor and save the contents as /etc/ypserv.conf:

192.168.3.:home:*:none

Change 192.168.3. to the IP of your network. By leaving the final component of the IP empty, the entire range of addresses in the network, .1-.254, will be served by the NIS server.

To set the domain name on the server to 'home', type the following in a shell as root:

$ domainname home

Now the server can be started. If you installed the server from a package provided by your distribution, you can start it by typing in a shell as root:

$ /etc/init.d/ypserv

Otherwise, you can start the server by typing in a shell as root:

$ rpcinfo -p localhost ypserv

Once the server has started, you must initialise the databases by typing in a shell as root:

$ /usr/lib/yp/ypinit -m

You will be prompted to enter the hostnames of the servers on your network. The hostname of your machine will be entered for you automatically, so press <Ctrl>-D immediately to initialise the NIS server. Now the server is running and ready to serve clients.

Each time you add a user to the system you must rebuild the NIS database so that the changes propagate to the rest of your network. To rebuild the NIS database, type in a shell as root:

$ make -C /var/yp

Setting up the client

To set up a client for the NIS service, edit or create the text file /etc/yp.conf with a text editor. Add the following to the file:

domain <domain> server <server_ip>

Replace <domain> with your NIS domain - in our case, 'home' - and <server_ip> with the IP of your NIS server, in our case, 192.168.3.1.

A copy of the Linux NIS client, ypbind, was included on this May's cover CD. Most Linux distributions include the client, and this should be used if possible.

To connect the client to your NIS server, type the following in a shell while logged in as the super user:

$ /usr/sbin/ypbind

To test that you have connected to the NIS server, type the following:

$ /usr/sbin/ypcat passwd

If you are successful, this will display the contents of the file /etc/passwd on the NIS+ server.

You can automatically connect to the NIS server by adding the command used to connect to the NIS server to the file /etc/rc.local. The /etc/rc.local script is a plain text file and is run when your system boots.

After setting up the client on each of your computers you will be able to use the same username and password to log in. Next month I will show you how to network your home directories, allowing you to access the same desktop on each computer.

Join the PC World newsletter!

Error: Please check your email address.

Our Back to Business guide highlights the best products for you to boost your productivity at home, on the road, at the office, or in the classroom.

Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Alastair Cousins

PC World
Show Comments

Essentials

Microsoft L5V-00027 Sculpt Ergonomic Keyboard Desktop

Learn more >

Lexar® JumpDrive® S57 USB 3.0 flash drive

Learn more >

Mobile

Lexar® JumpDrive® S45 USB 3.0 flash drive 

Learn more >

Exec

Lexar® Professional 1800x microSDHC™/microSDXC™ UHS-II cards 

Learn more >

HD Pan/Tilt Wi-Fi Camera with Night Vision NC450

Learn more >

Audio-Technica ATH-ANC70 Noise Cancelling Headphones

Learn more >

Lexar® JumpDrive® C20c USB Type-C flash drive 

Learn more >

Budget

Back To Business Guide

Click for more ›

Most Popular Reviews

Latest News Articles

Resources

PCW Evaluation Team

Michael Hargreaves

Windows 10 for Business / Dell XPS 13

I’d happily recommend this touchscreen laptop and Windows 10 as a great way to get serious work done at a desk or on the road.

Aysha Strobbe

Windows 10 / HP Spectre x360

Ultimately, I think the Windows 10 environment is excellent for me as it caters for so many different uses. The inclusion of the Xbox app is also great for when you need some downtime too!

Mark Escubio

Windows 10 / Lenovo Yoga 910

For me, the Xbox Play Anywhere is a great new feature as it allows you to play your current Xbox games with higher resolutions and better graphics without forking out extra cash for another copy. Although available titles are still scarce, but I’m sure it will grow in time.

Kathy Cassidy

STYLISTIC Q702

First impression on unpacking the Q702 test unit was the solid feel and clean, minimalist styling.

Anthony Grifoni

STYLISTIC Q572

For work use, Microsoft Word and Excel programs pre-installed on the device are adequate for preparing short documents.

Featured Content

Latest Jobs

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?