Shell Script For Password
I am working on a script to set/change passwords for users. The script prompts you for the username and then the password. They are stored in variables: $uname and $pword. The script then runs passwd $uname. The output is this:
passwd chris new password: What I need to know at this point is how to get the value of $pword to be the input for the new password. Thanks, Chris |
You'll want to look into expect... I'm not sure how to use it, but
Code:
man expect |
I'm not sure what you want to do. Why don't users simply use the passwd program?
|
Because there is about 6 different places they would have do do it, I am working on a script that will take that password and pass it and change it in other places to keep them syncronized so the users just have to keep up with one password.
|
You might consider using ldap or nis+. I don't have the experience on installing or using them to give you a how-to however.
Another option is using 'cfengine'. This is often used to distribute changes to many machines. Another option is to use ssh to securely send the password to the other machines. About setting the password prompt to $pword, I think using a here document might work. Code:
passwd $uname <<+ For using NIS http://davidcoulson.net/writing/pcp/...inuxexpert.pdf Using OpenLDAP: http://www.yolinux.com/RH-LDAP/s1-ldap-redhattips.htm Explaining HERE documents: http://www.linux.com/guides/abs-guide/here-docs.shtml There are probably how-to's in the tldp.org website. |
All times are GMT -5. The time now is 07:25 AM. |