I'm trying to set my password with echo "user:SOME_PASSWORD_STRING" | sudo chpasswd -e
but when I do this, my password is not set to the correct password. The passwords I'm using are one's I've copied from /etc/shadow
.
1 Answer
The problem is the use of double quotes in the echo statement. The password had several $
characters in it, which was translated as bash variables.
The correct command uses single quotes:
echo 'user:SOME_PASSWORD_STRING' | sudo chpasswd -e
See here for more on quotes: Differences between doublequotes " ", singlequotes ' ' and backticks ´ ´ on commandline?
/etc/passwd
? Aren't we supposed to store those in/etc/shadow
which is inaccessible to regular users for security reasons? I really hope you're not operating any publicly accessible servers./etc/shadow
. Fixed