The best way to solve this is by using kerberos as mentioned before.
As an alternative to kerberos, on how you can achieve the same goal while using NFS4, considering you wanna do this for a few machines in your home.
Lets have in mind you are sharing the directory /mnt/public
- exported it like:
/mnt/public 192.168.1.0/24(rw)
The question mentions a way to map users, my understanding is the goal is have a way to cross-connect users access with a simple NFS shares. So I'm mapping groups instead of stand-alone users. The same logic can be used for users by using SUID instead of SGID
- We need a specific GID to be in all our devices
groupadd homeshare -g 27000
The clients will also need the same GID, that means manually create a group with ID 27000 in all the clients.
- Create the public directory with GSID permissions:
mkdir -p /mnt/public
chmod g+s /mnt/public
chown :homeshare /mnt/public
the public share must use group suid and be owned by the group you've just created
As a plus define a password for the group in the clients.
Use newgrp
to login on it.
With that, you don't need to add all the users to the group, only the ones who you shared the group password will have access.
Example:
gpasswd homeshare # define the password to the group
newgrp homeshare #login in the group using the password
uid=
is from SMB, I think - looking for the same as you with NFSv3, still confused :/