How to add a user without knowing the encrypted form of the password?
You can use openssl to generate pre encrypted password strings to use with the -p option to useradd
echo "P4sSw0rD" | openssl passwd -1 -stdin
$1$Jxmpx1Da$Y8MzBctIyDW8/7pFPbNWD1
The -1
says to generate a MD5 password hash. The salt is automatically generated.
You can then use
useradd -d /home/dummy -g idiots -m -p $(echo "P4sSw0rD" | openssl passwd -1 -stdin) dummy
to add the user. To do this interactively hiding the password
useradd -d /home/dummy -g idiots -m -p $(read -sp Password: pw ; echo $pw | openssl passwd -1 -stdin) dummy
Apparently, you can use
echo "password" | passwd dummy --stdin
I've never tried this.
Alternatively, you could put the user's public key in /home/dummy/.ssh/authorized_keys
and forget about passwords entirely. This is the best option security-wise.