Shell script to change the password

Hi Folks,

I am trying to change the password for the user "sysservice"
Where my requirement is login to each server and exit from that and ssh to the next server.. I have enabled the password less auth for the user sysservice.

for i in `cat /home/sysservice/servers.txt`
do
ssh sysservice@$i ;
echo "P@ssw0rd" | passwd --stdin sysservice $i
done
exit


 

Your echo occurs after the ssh session has been closed. You need to give it to ssh , either by passing it as a command line parameter, or via stdin, by using e.g. a "here-document".