Changing user password in multiple servers


Author: Rajesh

Version: 1.1

# Make sure that you have created a file with servers list in it. Hostname or ip. One name or ip in each line. The script will ask you to enter the filename as it is.

echo "Enter the username for which you want to change the password \n"

read USER

sleep 2

echo "Enter the password that you would like to set for $USER \n"



echo "Enter the file name that contains a list of servers. Ex: servers.txt, host_list.txt OR WHATEVER YOU HAVE NAMED IT \n"

read FILE

sleep 2

echo "Enter the path of the directory where the $FILE is present. Ex: /root, /tmp OR WHEREVER YOU HAVE PLACED IT"

read PATH

sleep 2

for HOST in $(cat $PATH/$FILE)


ssh root@$HOST  "echo -e '$PASSWORD\n$PASSWORD' | passwd $USER"



Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.