Is it possible to change the password using a shell script, I want to remotely connect to a computer and then change password without manual intevention.
Thanks in Advance
Rishi
Is it possible to change the password using a shell script, I want to remotely connect to a computer and then change password without manual intevention.
Thanks in Advance
Rishi
I reckon so but you may have to be cunning with allocating virtual terminals.
for instance I tried
ssh -T $IP "passwd oracale"
but unfortunately this prompts for new password, which i dont want and I want to pass the new password as argument to script itself.
You need the far end to allocate a virtual terminal and pass the password in stdin.
you can use expect's passmass script, or construct more simple one like :
#!/usr/bin/expect
set timeout -1
spawn ssh@host
expect "password:"
send "the-pass-goes-here\r"
sleep 1
spawn passwd [lindex $argv 0]
set password [lindex $argv 1]
expect "password:"
send "$password\r"
expect "password:"
send "$password\r"
expect eof
exit
This will, however, pose a security risk, by enclosing password in plain file.
I copied this example from http://floppsie.comp.glam.ac.uk/Glamorgan/gaius/scripting/5.html, you will find great examples of Expect and scripting explanation.