Linux user at two separate machine

We have a requirement to have the same user at two Linux machines. On first box the application will write with a specific user on a NFS volume, the same volume mounted on another linux box where as 3rd party script will pick up these files which same user.

Can we have same user at two linux machines? Do I need to take care of gid and uid?


Solution 1:

It's recommended, or at-least I would personally recommend you sync the group ID and user ID. There are many ways to do, and maintain this consistently - I'll go over three options.

Manually:

You can manually add the user to each host, the first SSH into both hosts then execute useradd -u 1500 testuser replacing testuser with a preferred username.

This will create a user with the GID/UID of 1500, which you can confirm with id testuser which should give you something like uid=1500(testuser) gid=1500(testuser) groups=1500(testuser)

SaltStack:

This will require some more learning if you're not familiar with SaltStack but here is a really simple state.

testuser:
  user.present:
    - fullname: 'Test User'
    - uid: 1500
    - gid: 1500

Reference: https://docs.saltstack.com/en/3000/ref/modules/all/salt.modules.useradd.html

(There are other options for configuration management, such as Ansible, Puppet, Chef)

Centralised:

There are a few options, but a popular one is FreeIPA which is a good all-in-one solution when it comes to centralised Linux authentication.

Of course, this option is more involved and will require you do some research - but there are tonnes of guides on how to install and configure this, such as this one.