1832993 Members
2450 Online
110048 Solutions
New Discussion

Script help

 
SOLVED
Go to solution
Mike_305
Super Advisor

Script help

Hi,

Does any one has a script in place or any idea on changing root passwd on multiple system. I realy don't want to rlogin in each system and do "passwd root". I would like to use script.

Thanks in advance.

Mike
If there is problem then don't think as problem, think as opportunity.
10 REPLIES 10
hari jayaram_1
Frequent Advisor

Re: Script help

Mike,

Do yoy have a system which is trusted by all other servers if yes then I can give you a script to do the password change.

Thanks

Rgds

Hari
Mike_305
Super Advisor

Re: Script help

No all the system are non trusted and it's combination of Sun, IBM, and HP.

Thanks,

Mike
If there is problem then don't think as problem, think as opportunity.
Jeff Schussele
Honored Contributor

Re: Script help

Hi Mike,

Your best bet would be to use an Expect script - mainly because of it's interactive capability.
Can be obtained at

http://dsportal.eservices.hp.com/dspp/tech/tech_TechSoftwareDetailPage_IDX/1,1703,543,00.html

Someone may already have an Expect script written....

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
SHABU KHAN
Trusted Contributor
Solution

Re: Script help

Mike,

If you have ssh configured across all your servers your task is simple. If you have the ability to ssh as root to all your servers ... then:

OWNER="root"
SYS_LIST="host1 host2 host3 host4 host5"
for HOST in "${SYS_LIST}"
do
echo "Changing Root passwd on ${HOST}................................"
/usr/local/bin/ssh ${HOST} /usr/bin/passwd ${OWNER}
echo "passwd changed successfully for ${HOST} ......................." done

should work ... You will be prompted for new passwd for each of these servers ... This is NOT TESTED ...

Thanks,
Shabu
Mike_305
Super Advisor

Re: Script help

Hi Shabu,

I modified your script but some how it hangs when it prompts me for new passwd. Any idea.

Mike
If there is problem then don't think as problem, think as opportunity.
Mike_305
Super Advisor

Re: Script help

Hi Shabu,

Here is the script.

OWNER="root"
SYS_LIST=`cat mike3`
for HOST in $SYS_LIST
do
echo "Changing Root passwd on ${HOST}................................"
/usr/bin/rlogin -l root ${HOST} | /usr/bin/passwd ${OWNER}
echo "passwd changed successfully for $HOST ......................."
done

Mike
If there is problem then don't think as problem, think as opportunity.
SHABU KHAN
Trusted Contributor

Re: Script help

Hi Mike,

Thank You ! You just made me a ITRC Graduate :-)

Okay ... I would test two things first:
prompt>cat mike
host1 host2 host3 host4 ...

1) Try changing:
the first line (for loop)
to:

>for HOST in `cat /tmp/mike`

2) Try manually from the command prompt:

prompt>/usr/bin/rlogin -l root host1 | /usr/bin/passwd root

I've executed other commands using ssh before and it works. I use it to create logins for users across servers ...

Did you check the rlogin syntax ?

All the best !
-Thanks,
Shabu
Mike_305
Super Advisor

Re: Script help

Hi SHABU,

Not running SSH on the server. Is their any other way I can do this.

Mike
If there is problem then don't think as problem, think as opportunity.
hpuxrox
Respected Contributor

Re: Script help


Well you can do this a many number of ways.
I sometimes just cut and paste the encyped password into wordpad then vipw and paste in the new encyped key.

I have in the passed used expect to do this too.

One other suggestion is to use NIS for managing the systems passwords, but there are some security concerns that come along with that.


Sachin Patel
Honored Contributor

Re: Script help

Yes Mike,
I had same problem like you. I go to one system then run script. I might have to type passwd 100 time but I am sure that it works.

#!/bin/sh
for i in `cat systemlist`
do
rlogin $i
#then I change passwd.
done

#cat systemlist = my systems names one in one line.

Sachin
Is photography a hobby or another way to spend $