Same password in different linux machines

0

Perhaps this is old.

How do I do to manage the same passwords in different linux machines for the same list of users? I was told that copying the /etc/shadow for every user in the new machine would work.

In any case, this is what I do: Create a new user account $adduser user, go to /etc/shadow and replace the user line by the line given in the old machine. This worked for some user, but not for another.

user2820579

Posted 2015-09-07T17:28:02.033

Reputation: 101

Answers

1

You can do a simple bash script that would iterate over an existing list of users and copying their password. Passwords are "portable" - If it works in a machine, the same hash should work in a different machine.

Additionally, you can use the -p flag of the useradd command:

-p, --password PASSWORD
    The encrypted password, as returned by crypt(3). The default is to disable the password.
    Note: This option is not recommended because the password (or encrypted password) will be visible by users listing the processes.
    You should make sure the password respects the system's password policy.

You won't echo the password on the command line but your script will iterate, so noone will see the user list. So your command could be something like this (for each iteration):

useradd myuser -s /bin/bash -m -p $6$...

nKn

Posted 2015-09-07T17:28:02.033

Reputation: 4 960

0

If you have a server that’s permanently powered on and if you think your network of users will be growing, it might be worth learning how to install and configure Network Information Service.

If your network is growing and / or user’s passwords change often, using NIS should (I haven’t yet used it myself) be more sustainable than manually copying password / shadow files.

Anthony Geoghegan

Posted 2015-09-07T17:28:02.033

Reputation: 3 095