Change root password remotely


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Change root password remotely
# 1  
Old 05-05-2011
Question Change root password remotely

Hi All,
Hope you all doing well...!!!
First of all i will like to share few information about my network.
I have a network of 50 solaris servers sample IPs are (10.2.135.1 to 10.2.135.50)..
i have created trust for root user of servers 1(10.2.135.1) in all other servers, that is i have shared the authentic public key between 1 and other 49 servers.
With this i am able to login in other servers using root user without passing the password even.

My problem starts here:-

My aim is to change the root password of all the 49 servers while sitting in server1(10.2.135.1).
please suggest me script which help me in this.


Smilie
# 2  
Old 05-05-2011
expect will do what you need.

with expect you can ssh to the remote box, run passwd, enter in the info, confirm it and exit the ssh session.

---------- Post updated at 12:31 PM ---------- Previous update was at 12:21 PM ----------

quick example... this probably wont work.. I did it all off the top of my head.

Code:
#!/usr/bin/expect -f

set ipaddress [lindex $argv 0]
set password [lindex $argv 1]

set timeout 10
spawn ssh -o StrictHostKeyChecking=no -o Batchmode=yes root@$ipaddress
expect {
  blah@blah# {
    send "passwd\r"
    expect {
      New Password: {
        send "$passwod\r"
	expect { 
	  Reenter New Password: {
	    send "$password\r
          }
        }
      }
    }
  exp_continue 
  }
  "Password changed." {
   return 0
  }
  timeout {
  return 1
  }
}
expect eof

# 3  
Old 05-05-2011
Here is a script that you can use (see attached). You will have to modify it a bit because it is based on a source HP-UX box. But it will push out to most *NIX flavors.
# 4  
Old 05-05-2011
I don't know solaris....but, why don't you just copy /etc/passwd (or the shadow file) from 10.2.135.1 to the rest of the servers?

And have all the users change their passwords on 10.2.135.1.
This User Gave Thanks to purdym For This Post:
# 5  
Old 05-09-2011
Hi purdym, i liked your way but what if the file while SCP gets corrputed and the passwd file gets corrupted and then the same replaces the other passwd file of other servers, in that case i will fail to login in any of the servers..
There is a big risk in doing that.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Can a root role change the root password in Solaris 10?

i do not have root on a solairs 10 server , however i do have the root role, i was wondering if I can change the root password as a a role with the passwd command? I have not tried yet. and do i have to use the # chgkey -p afterwards? i need to patch is why i am asking. thanks (1 Reply)
Discussion started by: goya
1 Replies

2. Ubuntu

Root access that can't change root password?

We are having a little problem on a server. We want that some users should be able to do e.g. sudo and become root, but with the restriction that the user can't change root password. That is, a guarantee that we still can login to that server and become root no matter of what the other users will... (2 Replies)
Discussion started by: 244an
2 Replies

3. Red Hat

Change password of linux servers remotely

Hi, I am very bad at scripting. I need help from scripting experts... I need to change password of around 100 linux remote servers. I have been given a script for changing the password that automates the task. however I do not understand the usage and meaning of the script, the script is an... (0 Replies)
Discussion started by: renuka
0 Replies

4. Solaris

Solaris 8 - Asks for current root password when trying to change root password.

Hello All, I have several solaris boxes running Solaris 8. When changing root passwords on them, all will simply ask for the new root password to change and of course to re-type the new password. One of the systems however asks for the existing root password before it will display the new password... (8 Replies)
Discussion started by: tferrazz
8 Replies

5. Shell Programming and Scripting

how to change root password using shell script with standard password

Hi Friends. I am new to scripting now i want to change the root password using the script with standard password. which is the easy scripting to learn for the beginner, Thanks in advance. (2 Replies)
Discussion started by: kurva
2 Replies

6. HP-UX

Change root password?

Hello! I forget the root password and I need to change it. I've read others threads about it in this forum, but it seems it's necessary to modify /etc/passwd file. In my HPUX Systems this passwd file have only "read" permissions ant its owner is the root user, so how can i modify this file, if I... (4 Replies)
Discussion started by: kaugrs
4 Replies

7. UNIX for Advanced & Expert Users

using ssh change password remotely?

Is it possible to change the password using a shell script, I want to remotely connect to a computer and then change password without manual intevention. Thanks in Advance Rishi (4 Replies)
Discussion started by: RishiPahuja
4 Replies

8. Solaris

change root password

Hi, please advise me what is the simplest way to change root password on Sun Sparc 64 bit with Solaris 9 on it. Thanks in advance. (3 Replies)
Discussion started by: duke0001
3 Replies

9. HP-UX

How to change root password on HP UX

Hello, I try to make a change on the root password on HP UX. I use sam but it didn't work here. I try to login as root but I failed however, I login to my name and then change to su and su password then it is o.k There is not much different from root and su but how do we use root? Thanks so... (4 Replies)
Discussion started by: mle06
4 Replies
Login or Register to Ask a Question