Thanks for the sshpass, it works with sshpass. I had already tried and your code too did worked.
But thing is that i need to execute it without sshpass, and on servers where sshkeys are not already present.
i used below code in the script with just ssh -t option and got below error, can you please let me know how to resolve this two issues using ssh.
ssh -t $ADMIN@$hostname 'echo -e \"$TARGETPASS\n$TARGETPASS\" | passwd $TARGET'
After executing the script: below is the o/p:
Enter User name with Sudo Previleges which will be used to change the passwords on remote Servers
admin
Enter Password for oracle
admin123
Enter User name Whose passwords needs to be changed on remote Servers
test
Enter NEW password for test user
abcd
resetting password for test on 10.180.91.17 using oracle@10.180.91.17
admin@10.10.11.12's password:
Changing password for admin oracle.
Changing password for admin.
(current) UNIX password: passwd: Authentication token manipulation error
Connection to 10.10.11.12 closed.
resetting password for test on 10.10.11.13 using admin@10.333.23.33
and so on..............for other servers in the serverlist
Can you please suggest how to overcome this issue......(without sshpass and expect)
Surely there would be some way, which we arent aware of.
Thanks for the efforts taken.