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.
Asked
Active
Viewed 3,282 times
2
Zags
- 151
- 1
- 7
-
Wait… you have password hashes stored in `/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. – David Foerster Oct 16 '14 at 01:53
-
@DavidFoerster Oops. I meant `/etc/shadow`. Fixed – Zags Oct 16 '14 at 17:41
1 Answers
2
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?