Is there a way to change user password using passwd command in shell script?
I don't want to use expect.
Please help
Is there a way to change user password using passwd command in shell script?
I don't want to use expect.
Please help
use the command passwd, it will ask for old password and then the new password twice
I want to use it in a script without my interaction. I want to provide new password in a script a than run passwd to change user password.
Problem of using passwd in shell script is that passwd requires user interaction to change password and script stops. My question was is there a way to use passwd without interaction or is there other way to change password using shell script
To do what you want you would need to embed your password in a script in plain text - not good for security! Do you really want to do this?
Yes I want
From my man page on passwd... . Yours might not accept input from a script, depending on the system.
PASSWD(1) User utilities PASSWD(1)
NAME
passwd - update a user's authentication tokens(s)
...
--stdin
This option is used to indicate that passwd should read the new password
from standard input, which can be a pipe.
You could embed only the encrypted portion of the password and use sed to update /etc/shadow.
nathan - the "--stdin" option is not universial.
I had this problem, I thought about sed on the password file and/or shadow file but too risky. if sed stuffs up the file your ALL users are doomed!
The safest way was to install "expect" and use it eith as an expect script or from withion a shell script.
Basiccly passwd will always stop and request command line input. Its a security thing....
mdhmi - You're absolutely right. The --stdin option isn't universal. Which is why I prefixed the statement with this: