NIS - Linux Central Authentication
NIS - Linux Central Authentication
NIS, (Network Information Services), enables account logins and other services (host name resolution, xinetd
network services configuration ...), to be centralized to a single NIS server.
This tutorial covers the configuration and use of NIS for login authentication. NIS+ is slightly more complex as it uses
encryption for the data transfers between the NIS server and NIS client. Regular NIS does not use encryption, thus it
should only be used for isolated or private networks protected by a firewall.
NIS Description:
NIS allows a central server to manage password authentication, host, services, etc which would normally be
provided by the local files /etc/passwd, /etc/shadow, /etc/groups, /etc/hosts, /etc/services, /etc/networks,
/etc/rpc, /etc/protocols, /etc/aliases (sendmail), ...
NIS Client systems look to the NIS server to provide this data. This tutorial will cover the configuration of both an
NIS server and NIS clients.
The logical cluster of the server and clients are known as an NIS "domain".
An NIS domain must have their time synchronized, usually using NTP (Network Time Protocol).
LDAP has overtaken NIS as the preferred central authentication server technology as it has cross platform support
and greater client web and desktop application support. See the following YoLinux LDAP tutorials:
LDAP authentication
LDAP server configuration
Website authentication using LDAP and Apache
NIS has greater legacy UNIX support and is in place and used in many corporate networks. NIS is independent of
NFS (file sharing) although the two are often hosted on a single server and they were both originally developed by
Sun Microsystems.
NIS Configuration:
NSCD is used by LDAP and NIS. Configuration of nscd defines which files are supported by NIS. i.e. authentication
requires passwd, shadow and group file support. Uses configuration file /etc/ncsd.conf
1
The following configuration assumes that the NIS server will also be using NIS for authentication.
File: /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=hostname-of-this-nis-server
NISDOMAIN=name-of-domain
File: /etc/yp.conf
Example:
domain lab2 server 127.0.0.1
Format:
domain name-of-domain server 127.0.0.1
Where 127.0.0.1 is the "localhost" IP address of the NIS server. In this configuration, this NIS server is using NIS to
authenticate logins, not just the client.
File: /etc/nsswitch.conf
passwd: files nis
shadow: files nis
group:
files nis
Order by which authentication methods are processed. eg. In this case, check the local /etc/passwd file first before
checking with NIS for password authentication. It is recommended that the root password be authenticated locally
using "files" with all other users authenticated using NIS.
File: /etc/ypserv.conf
dns: no
files: 30
slp: no
slp_timeout: 3600
xfr_check_port: yes
* : * : shadow.byname : port
* : * : passwd.adjunct.byname : port
File: /var/yp/securenets
Configuration authorizes only a single subnet to authenticate with the NIS server:
host 127.0.0.1
255.255.255.0 XXX.XXX.XXX.0
Allows the range of IP addresses 192.168.105.0 to 192.168.106.255 to authenticate with the NIS server.
Configuration to allow everyone to authenticate with the NIS server:
2
255.0.0.0 127.0.0.0
0.0.0.0 0.0.0.0
For more on the use of netmasks with IP addresses, see the YoLinux Networking tutorial and Subnets.
File: /var/yp/nicknames
passwd
group
networks
hosts
protocols
services
aliases
ethers
passwd.byname
group.byname
networks.byaddr
hosts.byname
protocols.bynumber
services.byname
mail.aliases
ethers.byname
Where:
The nisdomainname command creates the "NISDOMAIN" entry in /etc/sysconfig/network This is usually
configured during Linux OS installation. Note the commands nisdomainname, ypdomainname and
domainname all are soft equivalent. Without specifying an argument, the command returns the domain name.
ypinit -m: Configure the NIS server as a "master NIS server" with the option "-m". This will convert
/etc/passwd, /etc/shadow, hosts, ... files into NIS GNU dbm database format and generates a make file.
Traditional UNIX systems use ndbm database format.
cd /var/yp
make
NIS Clients:
o
See the YoLinux tutorial on the Linux init process and configuring your system to start services upon system boot.
3
Test:
Check if portmapper daemon is running and ypbind is a registered service: rpcinfo -u localhost ypbind
o
o
ypbind
portmap
yp-tools
nscd
File: /etc/sysconfig/network , (RHEL, Fedora, CentOS, ... Red Hat based Linux systems)
NETWORKING=yes
HOSTNAME=client-hostname
NISDOMAIN=name-of-domain
File: /etc/yp.conf
Example:
domain lab2 server 192.168.20.5
Format:
domain name-of-domain server XXX.XXX.XXX.XXX , Where XXX.XXX.XXX.XXX is the IP address of the NIS server.
File: /etc/nsswitch.conf
...
...
passwd: files nis
shadow: files nis
group:
files nis
...
...
Options:
Check if portmapper daemon is running and ypbind is a registered service: rpcinfo -u localhost ypbind
List passwd file: ypcat passwd
Note:
[Potential Pitfall]: If you find that the daemon ypbind on a client is crashing on a network which extends great
distances, has heavy traffic or is unreliable, try starting ypbind with the option "-no-ping".
Red Hat configuration fix, edit file: /etc/init.d/ypbind and change to:
... OTHER_YPBIND_OPTS="-no-ping" ...
This will keep ypbind from checking its network connection unnecessarily.
Red Hat GUI client configuration:
useradd -g user-group user-id (or, also create home directory: useradd -m -g user-group user-id)
Hostname resolution:
It is the predominant practice to use DNS (bind) for hostname resolution.
6
files nis
...
...
This configuration has the system look at the file /etc/hosts for a host name and then it looks to the NIS server.
NIS Slave:
/usr/lib/yp/ypinit -s nis-master-hostname: Configure the NIS server as a "slave NIS server" with the option "-s" and
state the "master" from which the NIS database transfer will occur.
Note: This is a change from the above single NIS master configuration.
Start the additional database transfer daemon: service ypxfrd start
Links:
Man pages:
Configuration Files:
/etc/yp.conf
/etc/ypserv.conf
/etc/netgroup
/etc/nscd.conf
/etc/nsswitch.conf
/etc/nickname
Glossary:
NSS: Name Service Switch. The /etc/nsswitch.conf, determines the order of lookups performed.
RPC: Remote Procedure Call, routines allow C programs to make procedure calls on other machines across the n/w
HostName: The name of the computer system. This is typically configured using Linux OS installation.
YP: Yellow Pages(tm), a registered trademark in the UK of British Telecom plc. forcing Sun to rename it to
NIS.
Host Name Resolution: The lookup by a client to find the IP address given the host name so that it can
create a network connection.