简体   繁体   中英

SSH password script using root

Hello I am trying to work on a SSH password script.

The user I am using is root because this is for a cluster of servers and the root user has password less entry to all of the other servers in the cluster.

What I have here works as on one server

echo "Welcome3 | passwd user1 --stdin"

This is the script i'm trying to user on the cluster.

export HOSTS="server1.server.com
server2.server.com
server3.server.com
server4.server.com
server5.server.com"

for i in $HOSTS
do
echo $i
ssh $i echo Welcome3 | passwd user1 --stdin
done

I get the message

"servername changing password for user user1 passwd: all authentication tokens updated successfully"

But when I go to login to the other servers with the new password it dose not seem to take.

Any thoughts would be appreciated.

Thanks in advance.

You changed the password of user1 on your local machine.

Try this:

ssh $i 'echo Welcome3 | passwd user1 --stdin'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM