cd ../articles

System Networking BTS SIO labs

Centralised logins with NIS and shared homes over NFS

Create a user once, log in anywhere with the same password and the same home directory. NIS and NFSv4 between two unprivileged LXC containers, with every test written down.

  • NIS
  • NFSv4
  • LXC
  • AppArmor

The goal of this lab: create a user once on a server, then log in on any client with the same name, the same password and the same home directory. NIS distributes the accounts, NFS shares the homes. Two unprivileged LXC containers, and every result checked by a test.

Why bother with NIS in 2026?

NIS (formerly Yellow Pages) is old, and unencrypted: in production you would use LDAP or FreeIPA. But it shows the mechanics of centralised identity very plainly: maps of passwd, group and shadow served over RPC, picked up by the client through NSS and PAM. Once you have seen it work, LDAP makes a lot more sense.

Architecture

RoleContainerAddressServices
ServerCT 102 nis192.168.1.102ypserv, yppasswdd, nfs-kernel-server
ClientCT 103 nis-client192.168.1.103ypbind, NFSv4 client
nis-nfs.svg
NIS accounts and NFS homes
NIS accounts and NFS homes
Text version
  CT 102 · nis (192.168.1.102)                CT 103 · nis-client (192.168.1.103)
 ┌───────────────────────────────┐   NIS    ┌──────────────────────────────┐
 │ ypserv / yppasswdd            │ ───────▶ │ ypbind → NSS → getent, login │
 │ /var/yp/tp.nis (maps)         │          │                              │
 │                               │   NFS    │                              │
 │ nfs-kernel-server  /home      │ ───────▶ │ /home  (mount nfs4)          │
 └───────────────────────────────┘          └──────────────────────────────┘
 NIS domain: tp.nis · Debian 13 · unprivileged LXC

Prepare the Proxmox host

Containers share the host kernel, so the NFS modules must be loaded on the host and kept across reboots:

modprobe -a nfs nfsd lockd
printf 'nfs\nnfsd\nlockd\n' > /etc/modules-load.d/nfs.conf

And the client container must be allowed to mount NFS at all. Without this, AppArmor blocks it with apparmor="DENIED" operation="mount":

pct set 103 --features "mount=nfs;nfs4,nesting=1"
pct reboot 103

NIS server (CT 102)

apt install -y nis rpcbind      # asks for the NIS domain: tp.nis
echo tp.nis > /etc/defaultdomain && nisdomainname tp.nis
echo '192.168.1.102 nis.home.lan nis' >> /etc/hosts   # the master must resolve its own name
/etc/default/nis
NISSERVER=master
NISMASTER=nis
NISCLIENT=true
YPPWDDIR=/etc
YPBINDARGS="-local-only"

Restrict who may query the maps. Without this, anyone who can reach the server can download the user list:

/var/yp/securenets
host           127.0.0.1
255.255.255.0  192.168.1.0

The step that cost me the most time: the default Makefile does not build a shadow map. No shadow map, no password hashes on the client, and every login fails.

/var/yp/Makefile
MINUID=1000        # only distribute real users
MINGID=1000
NOPUSH=true        # single server, no slaves
all:  passwd group shadow rpc services netid protocols

I kept a separate shadow.byname map instead of merging hashes into passwd, so the hashes are not mixed into the most widely read map.

/usr/lib/yp/ypinit -m           # confirm "nis", Ctrl+D, y
systemctl enable --now rpcbind ypserv yppasswdd ypbind
ypcat passwd                    # users with UID ≥ 1000

After adding or changing a user later: make -C /var/yp to rebuild the maps.

NFS export (CT 102)

/etc/exports
/home   192.168.1.0/24(rw,sync,no_subtree_check,root_squash)
apt install -y nfs-kernel-server
exportfs -ra && systemctl enable --now nfs-server
exportfs -v

root_squash maps root on the client to nobody on the share, so a client admin cannot write anywhere in everyone's homes.

NIS and NFS client (CT 103)

apt install -y nis rpcbind nfs-common
echo tp.nis > /etc/defaultdomain && nisdomainname tp.nis
echo 'domain tp.nis server 192.168.1.102' > /etc/yp.conf
/etc/nsswitch.conf
passwd:  files systemd nis
group:   files systemd nis
shadow:  files systemd nis
/etc/fstab
192.168.1.102:/home  /home  nfs4  rw,hard,_netdev  0 0
systemctl enable --now rpcbind ypbind
mount -a

hard makes writes wait for the server instead of failing silently (safer for home directories), _netdev delays the mount until the network is up. The old intr option is obsolete and ignored.

Tests

Every claim gets a command. Here are the ones that matter, with what I saw.

#TestCommandResult
1Server daemonssystemctl is-active rpcbind ypserv yppasswdd nfs-serverall active
2Client bound to serverypwhich192.168.1.102
3User comes from NIS, not localgetent passwd testnis vs grep testnis /etc/passwdfound / empty
4Authenticationsu - testnis, good then bad password (as a non-root user)OK / failure
5Password change from the clientyppasswdchanged on server
6Shared homewrite on 103, read on 102same file, UID 1000 kept
7root_squashtouch /home/x as root on 103permission denied
8Reboot bothfindmnt /home, ypwhichback on their own
9Server failuresystemctl stop ypserv, then ypmatchfails, recovers on start

Pitfalls worth knowing

No shadow map, no logins

Users resolve fine with getent passwd and still cannot log in. Add shadow to all: and rebuild the maps.

AppArmor blocks NFS in containers

The mount fails with a permission error that looks like an NFS problem. It is the container profile: features: mount=nfs;nfs4.

Modules belong to the host

modprobe inside a container does nothing useful. Load nfsd and lockd on Proxmox and persist them.

NIS is plain text

Hashes travel unencrypted and anyone allowed by securenets can read the maps. Fine for a lab on an isolated bridge, not acceptable on a real network.

What came next

The same accounts were then extended to Windows clients with a Samba domain controller, and the modern equivalent of the whole idea is the OpenLDAP lab.