How do I create a crypt(3) encrypted password in a Windows DevBox that a remote CentOS 7 server can interpret successfully when creating a new user account via the following useradd command in a bash script?
useradd -u 12345 -g users -d /home/username -s /bin/bash -p '$1$NNfXfoym$Eos.OG6sFMGE8U6ImwBqT1' username
For testing purposes, let's assume that the cleartext version of the password should be Whirlpool_Sauna_Soap
When I man useradd, I get the following for -p
-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.
I am using putty to log in to the remote CentOS 7 server from a Windows DevBox. I would like to scp the file that contains the script from the Windows DevBox to the remote CentOS 7 server, and then run the script via SSH connection.
C, butpythonhas docs.python.org/2/library/crypt.html and perl also does. So the question you need to answer is what tools you have on your Windows DevBox? Would you accept a solution that uses ssh to run a command on your CentOS box, and if so what do you have available on that box? Could you useuseraddroo create the account without setting the password and then usechpasswdto set it?