How to replicate user passwords across hosts using /etc/shadow file
Introduction Today I received an interesting requirement. A customer wanted their FTP users on several new servers (having the same username) to have the same password as that of the users on an older server. The problem was that they did not actually know the passwords of the users on the old servers. Also, the process had to be largely automated because it needed to be repeated on multiple machines. So, after some research, I was able to come up with a solution. The solution to this problem was to use the user entries from the /etc/shadow file. Before we delve into the details of how the /etc/shadow file entries for some users could allow us to replicate their passwords across several machines, let’s first understand the different fields of the /etc/shadow file. The /etc/shadow file is a text file and has permissions set to 400 i.e. -r——– and its ownership is set to root:root. This implies that it can be read by the root user only and is implemented as a needed security mechanism. Let’s view an entry from the file: [root@linuxnix ~]# grep sahil /etc/shadow sahil:$6$ufcRl1.z$HC2JFSgFZkFiprGQ/dzWIH9NcxmF.WqldAbbmy.ra4/uoAOdST.NhRZp/BKalt0JEOEdXSJj48uGJxnImuyRo0:17517:0:99999:7::: [root@linuxnix ~]# As you might’ve observed the /etc/shadow file uses the colon (:) as a delimiter to separate different fields. This is similar to the /etc/passwd file. The /etc/shadow has 8 different fields which are as follows: Username Username is user’s...
Read More