#!/bin/bash
#####################################################
# #
# 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 your login ID : "
read login_id
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 $login_id@$hostname "sudo passwd $username"
echo ">>>>>>>>> SUCCESSFULLY CHANGED THE PASSWORD >>>>>>>>>>"
done
else
echo "!!!!!!!!! your answer does not match to continue. Thank you!!!!!!!!!!!!"
exit 1
fi
exit 0
Here first you have to provide your login password to get sudo access
No comments:
Post a Comment