Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

7 Answers

up vote 3 down vote accepted

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.

share|improve this answer
add comment

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.

share|improve this answer
    
you also get bonus points for centralized authentication and management. –  neoice Oct 16 '09 at 13:42
add comment

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

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

share|improve this answer
    
Agreed. Fix the real problem, don't patch it. I implemented an AD domain and used Likewise Open (which creates UID/GIDs as a hash of the account in AD, so they're consistent across the entire infrastructure). Totally solved all of my problems. –  Matt Simmons Oct 17 '09 at 2:03
add comment

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
share|improve this answer
add comment

It's possible with at least some implementations via the map_static option on the export. See this writeup.

share|improve this answer
    
The map_static option isn't available in Red Hat (the version I'm using). Would be exactly what I want otherwise. –  Nick Pierpoint Oct 16 '09 at 11:28
add comment

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

share|improve this answer
    
This is the approach I've been using but without much success. I've the following in /etc/exports... "/dir client(rw,all_squash,anonuid=600,anongid=600)". I thought this would mean that whichever user access the site from "client" the files on the server would appear to be owned by whichever user had user and group ID of 600 on the client. I don't see this though. –  Nick Pierpoint Oct 15 '09 at 23:07
    
FWIW, in my experiments (Suse 10) anonid forces all permissions checks to be performed as if the user on the client was the anonid. New files are created with the anonid as well. All files are listed with the anonid as the owner which doesn't match any username on the client so they are listed as 1001.Maybe there is a configuration problem? Here is the exports line I used: /tmp/nfs_test xxx.xxx.xxx.xxx(rw,sync,all_squash,anonuid=1001,anongid=100) –  Mark Porter Oct 16 '09 at 16:11
add comment

You can use usermod command to change UID/GID of users on both systems. However, you should be careful when changing ids for system users (uid < 500).

share|improve this answer
1  
Are there any other things one should needs to take care of when changing UIDs and GIDs such as all the files and directories owned by that user or group? –  Ladadadada Jan 21 at 11:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.