Not quite easy.
Do you want to change multiple systems password using script or local system's password using script.
in fist case:
change password in one system (which can rsh to other system as a root).
Make sure you do not have special character in root
cat /etc/passwd |grep root
V5ETRTolkjfTiQ6 (something like this then run following script)
You might want to try this script first on few systems.
for i in system1 system2 system3......
do
RESULT=`/etc/ping $i -n 2 | grep "packet loss" | \
awk '{print $7}' |cut -d"%" -f1`
if [ $RESULT -le 90 ]; then
alive=`remsh $i date`
if [ -z "$alive" ] ; then
echo $i
echo "system is alive but restrected to run remsh"
echo "${i} is restrected to run remsh" >> pending_systems
echo ""
else
echo "\n\n"
echo $i
# Change the password
rcp ${i}:/etc/passwd ${passwdtmp}
OLDPASSWD=`cat ${passwdtmp} | grep "^root" | awk -F: '{print $2}'`
sed s/${OLDPASSWD}/${NEWPASSWD}/ ${passwdtmp} > ${passwdtmp1}
mv ${passwdtmp1} ${passwdtmp}
Empty=`cat ${passwdtmp} | grep "^root" | awk -F: '{print $1}'`
if [ "$Empty" = root ] ; then
cat ${passwdtmp} | grep root
echo "\nIs this correct [y/n]"
read ans
if [ "$ans" = y ] ; then
rcp ${passwdtmp} ${i}:/etc/passwd
fi
else #empty
echo "${i} has problem \n"
echo "${i} has problem \n" >> pending_systems
fi #empty
fi
else #Result
echo "\n$i is not alive\n" >> pending_systems
fi
done
echo "\n\n file pending_systems has list of machines whose password is not changed"
#End of script---------------------------------------
Note: Make sure to run this script on few systems only to test first. If you mess it up you will not be able to login as root. You have to reboot the system and change the password in single user mode.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.