Originally posted by: Wouter Liefting
Do you have "expect" available on the Linux client? There are several examples out on the net which allow you to use expect in combination with ssh to run the passwd tool remotely, and to let expect provide you with the proper responses.
The following script runs on my Linux machine (CentOS 6.4 with expect and ssh), and resets the password of the specified user account on the remote AIX system (AIX 7.1):
#!/usr/bin/expect -f
# wrapper to make passwd(1) be non-interactive
# username is passed as 1st arg, passwd as 2nd
set username [lindex $argv 0]
set password [lindex $argv 1]
set serverid [lindex $argv 2]
set newpassword [lindex $argv 3]
spawn ssh $username@$serverid
expect "assword:"
send "$password\r"
expect "\$ "
send "passwd\r"
expect "Old password:"
send "$password\r"
expect "New password:"
send "$newpassword\r"
expect "new password again:"
send "$newpassword\r"
expect eof
You call this script with ./scriptname <username> <oldpw> <servername> <newpw>.
Note that expect is only required on the Linux client, not on the AIX server. The AIX system is standard, but with SSH installed - although if you fiddle the script you can also use it with telnet. (To install expect on a Red Hat or RH-derived system, use yum install expect.)