Change passwd for bulk servers using SSH script


 
Thread Tools Search this Thread
Operating Systems Solaris Change passwd for bulk servers using SSH script
# 1  
Old 05-17-2010
Change passwd for bulk servers using SSH script

Hi,

I need to Change passwd for bulk servers using SSH script.

I have one server, from which i can reach all the servers without password via SSH.

There is some expect script, from which i can achieve it.

Can any one help me out here.

Thanks in advance.
Vicky
# 2  
Old 05-17-2010
Modify following as per your requirements (include ssh) :

Code:
#!/usr/local/bin/expect -f
# Password change shell script, tested on Linux and FreeBSD
# ----------------------------------
# It need expect tool. If you are using Linux use following command
# to install expect
# apt-get install expect
# FreeBSD user can use ports or following command:
# pkg_add -r -v expect
# ----------------------------------
# If you are using linux change first line
# From:
#!/usr/local/bin/expect -f
# To:
#!/usr/bin/expect -f
# -----------------------------------------------
# Copyright (c) 2006 nixCraft project
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------
# display usage
if {$argc!=2} {
   send_user "usage: $argv0 username password \n"
   exit
}
# script must be run by root user
set whoami [exec id -u]
if {$whoami!=0} {
   send_user "You must be a root user to run this script\n"
   exit
}
#
set timeout -1
match_max 100000
# stopre password
set password [lindex $argv 1]
# username
set user [lindex $argv 0]
# opem shell
spawn $env(SHELL)
# send passwd command
send -- "passwd $user\r"
expect "assword:"
send "$password\r"
expect  "assword:"
send "$password\r"
send "\r"
expect eof

Also just try to serch in google, you will get a lot materials...Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

A script to change password for all other servers

Hey Gurus, I have this requirement to change the password for other servers remotely from one server. So, I installed public keys on all servers and wrote the following script to do the job. Something appears to be wrong with my loop, as it only changes one server and ignores the rest. I'm... (24 Replies)
Discussion started by: Hiroshi
24 Replies

2. Shell Programming and Scripting

Ssh passwd less, shell script

Hi All, Wishes!! I need some help to prepare a script to copy the public key from admin host to multiple client hosts to make them login without password. Detailed : I have an admin host "admin1" and i generated sshkeygen, now i have id_rsa.pub and i have around 50 client hosts. i... (4 Replies)
Discussion started by: kumar85shiv
4 Replies

3. Shell Programming and Scripting

Bulk NIS Users Password Change

Hi All, I am having Solaris 5.10 acting as NIS. How do i change multiple user password in NIS in a batch. I have predefined users with their passwords to be set: Example: user1 password1 user2 password2 Pls advise. (0 Replies)
Discussion started by: yogajwa
0 Replies

4. Cybersecurity

Ssh acces without passwd from unique machine to all servers

hello i want to acces to many machines over LAN network from a unique machine , that allow me to use a SSH directly without password. i ama using redhat enterprise version . i didnt find the right way to realise that. what should i do at first ? (1 Reply)
Discussion started by: wassimpb
1 Replies

5. Shell Programming and Scripting

Need script to monitor change in /etc/passwd

Hi All, From Audit point of view, I need to add a script to my production Solaris servers. That should be able to mail me, if any user is added or removed. That means, I should get a mail, what user is deleted or added in /etc/passwd, i.e. if there is a change in this file, I should be... (8 Replies)
Discussion started by: solaris_1977
8 Replies

6. Shell Programming and Scripting

Help required to write shell script to change passwd

Hi All, I wanted to write a shell script which will change the expired passwd in oracle. Here is below what I am trying, #!/bin/sh set -x ORACLE_HOME="/optware/oracle/9.2.0.2_64" SQLPLUS="${ORACLE_HOME}/bin/sqlplus" PASS="xyz" PATH=$ORACLE_HOME/bin:$PATH... (0 Replies)
Discussion started by: gr8_usk
0 Replies

7. Shell Programming and Scripting

Change part of filenames in a bulk way

Hallo! I have generated lots of data file which all having this format: sp*t1overt2*.txt Now I want to change them in this way: sp*t2overt1*.txt The rest of the file names stay unchanged. I know this is kind of routine action in sed or awk, but dont know how! I tried this command: ... (6 Replies)
Discussion started by: forgi
6 Replies

8. Shell Programming and Scripting

Bulk move in ssh command

Hi All, I am getting an problem. I am using ssh command in shell script to copy all files from a dir to another. find /home/dee -type f ! -newer /tmp/new | xargs -i cp {} /home/past{} This works fine but when I replace cp with mv, nothing happens! not even error. Can anybody please... (0 Replies)
Discussion started by: Deei
0 Replies

9. Shell Programming and Scripting

Script:Change password on 1000+ servers

Hello Folks Scenario : I have a linux box (expect tool installed) which connects to 1000+ other boxes (either Solaris or AIX or Linux ) with a specific id and password using SSH. I now wish to write a script (Shell and/or expect and/or Python) which will change this existing password to a... (1 Reply)
Discussion started by: ak835
1 Replies

10. Shell Programming and Scripting

ksh script to change passwd

Hello All, I am trying to change a user passwd (one time password): cat /tmp/passwd mnop1234 mnop1234 #passwd abcd < /tmp/passwd (for some reason, it is not able to input the password from /tmp/passwd and comes back with "New Password: ") Is there a work around except using "expect". ... (1 Reply)
Discussion started by: solaix14
1 Replies
Login or Register to Ask a Question