When using NFS, how do I make user A on the server appear as user B on the client?

I have a couple of servers on which the UIDs and GIDs are different for the same user names and group names. When I NFS mount a directory ostensibly owned by the same user from one server to another, the user can't access the files because of the UID/GID mismatch.

Is there a way to map UIDs and GIDs?

Thanks.


AS far as I'm aware this isn't possible. You can map root to a different ID, but no one else.

You might find using CIFS slightly easier to make do what you want.


You might want to consider using LDAP. Your problem will just go away if you do. Additionally, it takes the pain out of "roaming" users who may have different UID/GID depending on what system they are using.

If LDAP seems intimidating at first, try a web based management tool like Gosa to get started. If you are already familiar with LDAP trees, phpLDAPadmin might offer you more flexibility.


bindfs 1.10 (a Linux userspace filesystem implemented via FUSE) mounts one directory to another location, optionally transforming UIDs/GIDs (and/or permissions) in the process.

bindfs --map=olduid1/newuid1:@oldgid1/@newgid1:... /olddir /newdir

See Wallace's answer if you are looking to have users on the client line up with users on the server.

However, if you are looking for all users on the client to be the same user on the server, you can add (all_squash,anonuid=#,anongid=#) in your /etc/exports file on the server to force all clients to be anonymous and then set the anonymous userid and group id


I previously answered a similar question: Mapping UIDs for NFS.

In short, use LDAP or some other system to synchronize your UIDs.