7

I want change 120 user's password. so I wrote sudo echo 'user:passwd' | chpasswd

but I had a message,

chpasswd: (user) pam_chauthtok() failed, error:
Authentication token manipulation error
chpaswd (line 1, user) password not changed

and also I tried another way using textfile, but I had same the message.

I can't solve this problem.

16

The usual way to change the password is to use the passwd(1) command.

If you want to use chpasswd(8) or usermod(8) you should carefully RTFM.

Be sure that the given password is compatible with the system configuration. And sudo should apply to the chpasswd command, so you probably want

echo 'user:passwd' | sudo chpasswd

In your case, sudo echo 'user:passwd' | chpasswd, the sudo is applied only to echo, which is incorrect.

  • 1
    would even make more sense to run the whole thing as root instead of issuing sudo all the time. – Fiximan Aug 18 '15 at 13:40
  • @Fiximan: this really depends upon the system configuration. On some systems using sudo would be very sensible. – Basile Starynkevitch Aug 18 '15 at 13:41
  • Off: Using sudo bash once might be even more sensible. – Lorinczy Zsigmond Dec 13 '18 at 4:27
3

IMHO, it is better not to keep the credentials in the bash history for the security concerns.

We can use the chpasswd command with using a file instead of passing from the command line. Pick your favorite text editor to edit file.

vim passwd

Then enter user:password, save and exit with :wq

cat passwd | sudo chpasswd

Then you should delete the file:

rm passwd

In this way, you wouldn't need to use terminal to pass your credentials.

New contributor
mgurcan is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

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.