Script to change password on linux servers over ssh
The remote machine(s) do not need expect installed. You can install expect on a local workstation or VM (virtualbox) or whichever *nix box, and write a wrapper that calls this .ex (expect) script (there may be small changes from distro to distro, this tested on CentOS 5/6):
#!/usr/bin/expect -f# wrapper to make passwd(1) be non-interactive# username is passed as 1st arg, passwd as 2ndset username [lindex $argv 0]set password [lindex $argv 1]set serverid [lindex $argv 2]set newpassword [lindex $argv 3]spawn ssh $serverid passwdexpect "assword:"send "$password\r"expect "UNIX password:"send "$password\r"expect "password:"send "$newpassword\r"expect "password:"send "$newpassword\r"expect eof