Wednesday, June 29, 2005

Script for changing the password

Subject: FW: SUMMARY: Script for changing the password

Hi Managers,

Here is the more compact version updated script . Thanks to "Andrew
Hall" for advising me to use case statement.This avoids using NFS mount.

#!/usr/bin/ksh -x
########################################################################
########
#Script Written on 27th June 05 .
#This script is used to change the root password of all unix hosts
#Make sure /usr/sysadm/scripts/minoti/all-hosts is updated with live
hosts before running this script
########################################################################
#######

for i in `cat /usr/sysadm/scripts/minoti/test-hosts`
do
OS=`remsh $i uname`
case $OS in
SunOS) rsh $i "rm /tmp/shad*"
rsh $i "cp -p /etc/shadow /etc/shadow.2706"
rsh $i "cat /etc/shadow|grep -v root>/tmp/shad1"
rsh $i "echo "root:1EDHxu0aw6jRE:12958::::::">/tmp/shad2"
rsh $i "cat /tmp/shad1>>/tmp/shad2"
rsh $i "cp /tmp/shad2 /etc/shadow"
rsh $i "/usr/sbin/pwconv"
rsh $i "chown root:sys /etc/shadow"
rsh $i "chmod 400 /etc/shadow"
;;
HP-UX) rsh $i "rm /tmp/shad*"
rsh $i "rm /tmp/pass*"
rsh $i "cp -p /etc/passwd /etc/passwd.2706"
rsh $i "cat /etc/passwd|grep -v root>/tmp/shad1"
rsh $i "echo "root:WkmiDJgfPbUB.:0:3::/:/sbin/sh">/tmp/shad2"
rsh $i "cat /tmp/shad1>>/tmp/shad2"
rsh $i "cp /tmp/shad2 /etc/passwd"
rsh $i "chown root:other /etc/passwd"
rsh $i "chmod 444 /etc/passwd"
;;
Linux) rsh $i "rm /tmp/shad*"
rsh $i "cp -p /etc/shadow /etc/shadow.2706"
rsh $i "cat /etc/shadow|grep -v root>/tmp/shad1"
rsh $i "echo
'root:"$"1"$"hluzjp3u"$"bwx/ZLLAM4qANpMXTvBLz1:12961:0:99999:7:::'>/tmp/
shad2"
rsh $i "cat /tmp/shad1>>/tmp/shad2"
rsh $i "cp /tmp/shad2 /etc/shadow"
rsh $i "/usr/sbin/pwconv"
rsh $i "chown root:root /etc/shadow"
rsh $i "chmod 400 /etc/shadow"
;;
IRIX*) rsh $i "rm /tmp/shad*"
rsh $i "/sbin/cp -p /etc/shadow /etc/shadow.2706"
rsh $i "/sbin/cat /etc/shadow|grep -v root>/tmp/shad1"
rsh $i "/sbin/echo "root:kN6gTIyyu5foo:12958::::::">/tmp/shad2"
rsh $i "/sbin/cat /tmp/shad1>>/tmp/shad2"
rsh $i "/sbin/cp /tmp/shad2 /etc/shadow"
rsh $i "/sbin/pwconv"
rsh $i "chown root:sys /etc/shadow"
rsh $i "chmod 400 /etc/shadow"
;;
*) echo "platform $OS not supported"
;;
esac
done

Regards
Minoti Koul

0 Comments:

Post a Comment

<< Home