SUMMARY: Script for changing the password

From: Koul, Minoti <koulmin_at_ugs.com>
Date: Fri Jun 24 2005 - 05:35:06 EDT
 Thanks for all the valuable replies I got .

1.Anthony D'Atri [aad@verio.net]
2.Tony van Lingen [tony.vanlingen@epa.qld.gov.au]
3.Tim Evans [tkevans@tkevans.com]
4.Polachak, Jason M CTR NAVSEA [jason.polachak.ctr@navy.mil####
Jason,Let me know if it helps
5.JULIAN, JOHN C (AIT) [jj2195@sbc.com]
6.Andrew Hall [halla3@corp.earthlink.net]
7.Brad_Morrison@capgroup.com
8.David Ledger [dledger@ivdcs.co.uk]
9.Shaw, Kevin [Kevin.Shaw@CAX.USA.XEROX.COM]

I should have mentioned in my original post that mine was hetrogeneous
env. Solaris,HP-UX,AIX,SuSE,RedHat,SGI.....
Lot of people recommended using expect but installing expect on all
platforms was a huge effort.This is how I finally did (again a crude way
as I had called in my original post)


root@pnqccase2:>cat changepass.sh
###################################################################

#!/usr/bin/ksh -x
for i in `cat /usr/sysadm/scripts/minoti/all-hosts` # 200 odd unix
systems
do
OS=`remsh $i uname`

        if [ $OS = "HP-UX" ]
then
        rsh $i "/u/koulmin/scripts/hppass.sh"        #/u/koulmin is an
automount
fi

        if [ $OS = "SunOS" ]
then
        rsh $i "/u/koulmin/scripts/sunpass.sh"
fi

        if [ $OS = "IRIX64" ]
then
        rsh $i "/u/koulmin/scripts/sgipass.sh"
fi

        if [ $OS = "Linux" ]
then
        rsh $i "/u/koulmin/scripts/linuxpass.sh"
fi
done
########################################################################
#####
Here are the contents of /u/koulmin/scripts/sunpass.sh

#/bin/ksh -x
rm /tmp/shad*
cp -p /etc/shadow /etc/shadow.2406
cat /etc/shadow|grep -v root>/tmp/shad1
echo "root:1EDHxu0aw6jRE:12958::::::">/tmp/shad2 #encripted string of
changed password.
cat /tmp/shad1>>/tmp/shad2
cp /tmp/shad2 /etc/shadow
/usr/sbin/pwconv
chown root:sys /etc/shadow
chmod 400  /etc/shadow
########################################################################
########
Here are the contents of /u/koulmin/scripts/hppass.sh
Remember HP-UX does not maintain shadow file

root@pnqccase2:>cat /u/koulmin/scripts/hppass.sh
#/bin/ksh -x
rm /tmp/shad*
rm /tmp/pass*
cp -p /etc/passwd /etc/passwd.2406
cat /etc/passwd|grep -v root>/tmp/shad1
echo "root:WkmiDJgfPbUB.:0:3::/:/sbin/sh">/tmp/shad2
cat /tmp/shad1>>/tmp/shad2
cp /tmp/shad2 /etc/passwd
chown root:other /etc/passwd
########################################################################
#############
And so on for all platforms

Thanks once again to all who spared some time to share their valuable
inputs.

















-----Original Message-----
From: sunmanagers-bounces@sunmanagers.org
[mailto:sunmanagers-bounces@sunmanagers.org] On Behalf Of Koul, Minoti
Sent: Wednesday, June 22, 2005 11:03 AM
To: sunmanagers@sunmanagers.org
Subject: Script for changing the password

Hi Managers,
I am in a situation wherein I have to change root password of 100 odd
unix boxes. I wanted to do the same via a script.

I used to do it the crude way
#!/bin/ksh -x
cp -p /etc/shadow /etc/shadow.11
cat /etc/shadow|grep -v root>/tmp/shad1
echo "root:O75xmUttfitCw:12794::::::">>/tmp/shad2 ## here I am echoing
the encripted string for new password"
cat /tmp/shad1>>/tmp/shad2
cp /tmp/shad2 /etc/shadow
/usr/sbin/pwconv
chown root:sys /etc/shadow
chmod 400  /etc/shadow

I understand that we can input the new password via a script using !! .
But have'nt been able to do this successfully.
Can you please help out.



#####################################

MY NEW MOBILE  NUMBER: 9860092579

#####################################

Regards,

Minoti Koul

UGS - Pune, India

Direct: +91-20-22930635

Board:  +91-20-22930900

Cell:   +91-9860092579

E-mail: minoti.koul@ugs.com
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Fri Jun 24 05:36:20 2005

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:43:49 EST