script to change passwords for the same user on multiple servers

I am trying to write a script to change passwords for the same user on multiple servers.

My environment runs purely ssh / scp not rsh / rcp and therefore coping using rcp is not an option.

I have been playing with expect to perform tasks but think there must be a better way.

Has anyone got any ideas to help me out?

Would telnet work ?

Check this out - need script for passwd , can't use expect tool

I need to change my unix password over 10+ servers. I am not an SA, just a user. I am on Solaris 10 using ksh. I would like a script that runs through a host list and changes the password.

The script above is great, but we are not allowed to use telnet here at work. We have to use ssh to get into another server. I tried using ssh with the script above and it doesnt work. I can't use third party utilities. Any ideas would be greatly appreciated.

did you ensure a pseudo-terminal was allocated?

I get this message when it connects to the new server
"Pseudo-terminal will not be allocated because stdin is not a terminal."

So how do I allocate the Pseudo-terminal? And if I do it, will the script run in your opinion?

Thanks

I actually found out how to force psuedo terminal

ssh -T

So, now the code seems to work up until it trys to pass the $OLDPASS variable. It just sits there at the password prompt on the remote server

#
#  Section 1 --- Prove that we can talk with the hosts in HOSTLIST
HOSTLIST="myserver.net"
DELAY=3
stty -echo
print -n Enter Old Password-
read OLDPASS
print
print -n Enter New Password-
read NEWPASS
print
stty echo
USER=$(whoami)
exec 4>&1


#
#  Section 1 --- Prove that we can talk with the hosts in HOSTLIST
#     Part 1 --- telnet to each and touch a file

for HOST in $HOSTLIST ; do
        ssh -T $HOST >&4 2>&4 |&
        sleep $DELAY
        ##print -p $USER
        sleep $DELAY
        print -p $OLDPASS
        sleep $DELAY
        print -p touch changepassdatafile.$HOST
        sleep $DELAY
        print -p exit
        wait
done

Any ideas on why the password variable won't get passed on?

Yes I would like to know why the password is not passed in. It works great when using telnet, just not for ssh.