Hello,
Many thanks for the script posted by Perderabo. I came across it many years ago, and it was an immense help in automating a password change on a number of servers and for a number of accounts on those servers.
Now, I am in need of a script to do the same thing using SSH since our Unix Admins have disabled the Telnet process and are forcing only SSH access.
Searching this web site and the internet for any assistance, it plainly became clear that the 'expect' package was the only solution that would do something similar to Perderabo's script.
But,
I had setup SSH authentication, copying the source servers RSA tokens to the destination servers authorized_keys file.
I changed Perderabo's script to have just the two sections - 0 and 2. 0 to set the script up, request passwords, etc. and 2 to do the actual password change.
I then changed 'telnet' to be 'ssh -t -t' and removed the USER and OLDPASS prints, since they are not needed due to the SSH automated authentication.
Quote:
#!/bin/ksh
HOSTLIST="<destination server>"
DELAY=3
stty -echo
print -n Enter Old Password-
read OLDPASS
print
print -n Enter New Password-
read NEWPASS
print
stty echo
exec 4>&1
for HOST in $HOSTLIST ; do
echo "Changing ${HOST} password:"
ssh -t -t $HOST >&4 2>/dev/null |&
sleep $DELAY
print -p passwd
sleep $DELAY
print -p $OLDPASS
sleep $DELAY
print -p $NEWPASS
sleep $DELAY
print -p $NEWPASS
sleep $DELAY
print -p exit
wait
echo "Changed ${HOST} password!"
done
exit 0
This works for me ... it will connect via SSH to the destination server and does the password change.