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

[root@P-dude dude]# cat /etc/shadow | grep pswayze
pswayze:nf.IRWTMy0FHrPeaCjkahfufIIxnzxPZL7yg8SsvOdbjEpoI0G8uy7AqduYKQOn2R/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

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

1 Answer 1

67

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.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .