here is the picture:
a website on server1 & a "username" logged in that site.
The same username has a shell(nologin)/ftp/samba/mail(qmail) acount on server2.
i have s form on server1 that can pass the username & its NEW password to a sript that should change all passwords on server2.
the script must be executed as root on server2, as you can't do "vpasswd username@domain.com" as nonroot.
Thought of expect to do this, but just cant put it all together.
----
server1> ssh root@server2
passwd username
/home/vpopmail/bin/vpasswd username@domain.com
exit
send back result as "success" or "failed"
----
hope you guys can help
http://sarg.sourceforge.net/chetcpasswd.php
This might be what i need, but still will appreciate other sugestions
regards
I'm not sure I follow your question, but here is a script to look at...
changepass automate password changes on multiple systems
more details:
i have shell (bash) access to that RedHat linux and have the root password.
What i need is a simple script to take user+pass & do
/usr/sbin/chpasswd $1:$2
/home/vpopmail/bin/vpasswd $1@domain.com $2
Just my scripting is very bad and must do it before i have time to learn
Again RTFM did the trick
The following tool just watches your input in the console & generates the script for you. Enjoy it!
http://expect.nist.gov/example/autoexpect.man.html
http://expect.nist.gov/example/autoexpect
here is my "remote change passwd" script:
----------
#!/usr/bin/expect -f
#
set force_conservative 0
#
set timeout 1
spawn ssh root@srv
match_max 100000
expect "Last login: *\r\r
e\]0;root@srv:~a\[root@srv root\]# "
send -- "passwd USR\r"
expect "passwd*\r
Changing password for user *.\r
New password: "
send -- "PWD\r"
expect -exact "\r
Retype new password: "
send -- "PWD\r"
expect -exact "\r
passwd: all authentication tokens updated successfully.\r
e\]0;root@mail:~a\[root@mail root\]# "
send -- "/home/vpopmail/bin/vpasswd USR@domain.com\r"
expect "/home/vpopmail/bin/vpasswd \r
Please enter password for: "
send -- "PWD\r"
expect -exact "\r
enter password again: "
send -- "PWD\r"
expect -exact "\r
e\]0;root@mail:~a\[root@mail root\]# "
send -- "exit"
....
--------------------
This works great if I fill the values for USR & PASS in the script.
How can I pass these from the command prompt like:
#./myscript.exp USR PASS
and make the script use these
Thank you for the support