19
[root@P-dude dude]# useradd -p $6$Ic2PVlwi$2nf.IRWTMy0FHrPzaCjkahfu9IIxnzxPZL7yg8SsvOdbjEpoI0G8uy7AqduYKQOn2R/rnnaalRmfPMy.a0 bwong20

[root@P-dude dude]# cat /etc/shadow | grep pswayze
pswayze:nf.IRWTMy0FHrPzaCjkahfu9IIxnzxPZL7yg8SsvOdbjEpoI0G8uy7AqduYKQOn2R/rnnaalRmfPMy.a0:16924:0:99999:7:::

I'm not sure why the system removes the first fourteen characters from my encrypted password. The password in my /etc/shadow file is shorter than what I've provided as an argument to useradd -p

  • Of course, it should go without saying that you need to use a different password now you've exposed this hash. ;) – Wildcard May 4 '16 at 2:21
66

Because $ is a special character to the shell you should put the password in between single quotes:

useradd -p '$6$Ic2PVlwi$2nf.IRWTMy0FHrPza6mh5wjomwbYtIIxnzxPZL7yg8SsvOdbjEpoI0G8uy7AqduYKQOn2R/rnnaalRmfPMy.a0' bwong20

without these the shell will try to expand $6, $Ic2PVlwi and $2 to their respective variable values, and as the variables are not set, result in empty strings for each of them. Concatenated to the rest of the encrypted password string.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.