2

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.

2
  • 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. Oct 16, 2014 at 1:53
  • @DavidFoerster Oops. I meant /etc/shadow. Fixed
    – Zags
    Oct 16, 2014 at 17:41

1 Answer 1

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?

1
  • U saved me man !!
    – shweta
    Mar 16, 2021 at 13:00

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.