To change the password, I can run the following

echo "user:$npasswd" | chpasswd. 

...but after executing this it asks me to enter the current password.

Is there a way to automatically provide it with the current password?

0

1 Answer

as a user:

$ echo "rinzwind:2" | chpasswd Changing password for rinzwind. chpasswd: (user rinzwind) pam_chauthtok() failed, error: Authentication token manipulation error chpasswd: (line 1, user rinzwind) password not changed 

as root:

root@schijfwereld:~# echo "rinzwind:1" | /usr/sbin/chpasswd root@schijfwereld:~# 

You need to do it as "root". ANY other method of course will ask for the current password. It would be a security issue if you could alter it

When you do it as "root" it also accepts short passwords as you can see. Setting "1" as a password is not allowed by default from a normal prompt.

You can do

$ echo -e "1\naaaabbbb\naaaabbbb" | passwd rinzwind 

where 1 is the old password and aaaabbbb is the new password. The flow of passwd is: old password, enter, new password, enter, new password. Mind that the password is visible (if only for a brief moment) in the processlist.

5

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy