As example lets see you want to change password on one user on 100 servers. Well very easy...
login each server and execute 'passwd' command. :)
Here I try to automate this job. Anyway changing password is manual intervention. Here all servers required SSH enable and if you are not configured authentication keys you have login to each server
First you create list of servers and save it as server_list.csv (very easy when you use excel sheet)
then create script
#!/bin/bashYou have to know your current password to execute this script.
#####################################################
# #
# CHANGE PASSWORD ON REMOTE HOST #
# Version 1.2 #
# Created by Aruna #
# Created Date 21/12/2011 #
# Last Modified Date 22/12/2011 #
# INSTRUCTIONS- #
# Save both script and server_list.csv file in same #
# location #
#####################################################
host_name=""
file_name="server_list.csv"
echo -n "Enter username you want to change the password on the list of server : "
read username
echo -n " The username you entered is "$username". Is it correct (y/n)?"
read answer
if [ $answer = y ]
then
for i in $(cat $file_name);
do
hostname=$(echo $i| cut -f1 -d',')
ssh $username@$hostname 'passwd'
echo ">>>>>>>>> SUCCESSFULLY CHANGED THE PASSWORD >>>>>>>>>>"
done
else
echo "!!!!!!!!! your answer does not match to continue. Thank you!!!!!!!!!!!!"
exit 1
fi
exit 0
No comments:
Post a Comment