1

I have two ubuntu servers that share home directories. The /home directory from server1 is mounted as the /home directory on server2. I have a problem when trying to give a new person access to both servers. I use the adduser command on each server with the same user name. However the UID does not match when I do this, thus the user ends up not having permission to files in their home directory when it is accessed with the account from server2.

On server 1 where the user was created along with his home directory. (Things look okay)

selah@server1:~$ tail -n 2 /etc/passwd
dfulgon:x:1083:1087:,,,:/home/dfulgon:/bin/bash
swartp:x:1085:1089:,,,:/home/swartp:/bin/bash

selah@server1:~$ ll -a /home/dfulgon | tail -n 3
-rw-rw----  1 dfulgon dfulgon   25 Jun  2 13:41 .my.cnf~
-rw-r--r--  1 dfulgon dfulgon  675 Jun  2 13:35 .profile
drwxrwxr-x  2 dfulgon dfulgon 4096 Jun  2 14:27 .ssh/

On server 2 where a user account with the same name was created but the home directory from the other server is used: (Permissions are messed up, pointing to the wrong user)

selah@server2:~$ tail -n 2 /etc/passwd
bslf:x:1083:1087:,,,:/home/bslf:/bin/bash
dfulgon:x:1087:1091:,,,:/home/dfulgon:/bin/bash

selah@server2:~$ ll -a /home/dfulgon | tail -n 3
-rw-rw----  1 bslf bslf   25 Jun  2 13:41 .my.cnf~
-rw-r--r--  1 bslf bslf  675 Jun  2 13:35 .profile
drwxrwxr-x  2 bslf bslf 4096 Jun  2 14:27 .ssh/

Is there a good way to overcome this problem while maintaining the convenience of shared home directories?

2 Answers 2

1

The easiest thing to do is to create your accounts in some centeral database. These days almost everyone some form of an ldap database for this. But if you want to go with the insecure old-school method you could also look at NIS. (don't).

Another option is to use a configuration management tool to create your accounts, and keep the UIDs synced. So you could create your accounts with puppet and define the specific UID/GID you want.

You can do some things with the NFS id mapper to translate ids between system, but that can become a management nightmare.

1
  • I appreciate those suggestions! I think they are a bit heavyweight for what we are doing now. However, as our system gets more complex we will want to investigate these.
    – Selah
    Commented Jun 10, 2015 at 14:10
0

The solution we are going with:

Check both /etc/passwd files and choose the next appropriate GID and UID. Then specifying them during the user creation process like so.

addgroup -g $GID $username
adduser -g $GID -u $UID $username 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .