Sponsored Content
Top Forums Shell Programming and Scripting script to change passwords for the same user on multiple servers Post 302151163 by stringzz on Thursday 13th of December 2007 05:32:23 PM
Old 12-13-2007
I actually found out how to force psuedo terminal

ssh -T

So, now the code seems to work up until it trys to pass the $OLDPASS variable. It just sits there at the password prompt on the remote server

Code:
#
#  Section 1 --- Prove that we can talk with the hosts in HOSTLIST
HOSTLIST="myserver.net"
DELAY=3
stty -echo
print -n Enter Old Password-
read OLDPASS
print
print -n Enter New Password-
read NEWPASS
print
stty echo
USER=$(whoami)
exec 4>&1


#
#  Section 1 --- Prove that we can talk with the hosts in HOSTLIST
#     Part 1 --- telnet to each and touch a file

for HOST in $HOSTLIST ; do
        ssh -T $HOST >&4 2>&4 |&
        sleep $DELAY
        ##print -p $USER
        sleep $DELAY
        print -p $OLDPASS
        sleep $DELAY
        print -p touch changepassdatafile.$HOST
        sleep $DELAY
        print -p exit
        wait
done

 

10 More Discussions You Might Find Interesting

1. Solaris

Urgent !!! - Script to Change passwords in unix

I have SunOs 5.8. I need to change password using a unix shell script. I have tried to pipe the passwords to the passwd command but does not work. Pls provide a script to change passwds of a list of users using a shell script. ( I have also tried crypt() but did not work) The flow of the... (2 Replies)
Discussion started by: tofani
2 Replies

2. Shell Programming and Scripting

rsh to change multiple ip in multiple servers?

good day. i jsut wanted to know what is the best script or the best way changing a lot of Ip's in all servers. Do you have any idea? im using awk to change IP,what if, you have lots of servers. You need to change it one by one? It will take time to change it manually. (2 Replies)
Discussion started by: kenshinhimura
2 Replies

3. Shell Programming and Scripting

user id creation of multiple servers

Need help in creating a user with passord in mulptiple solaris servers using a script.. (0 Replies)
Discussion started by: ningy
0 Replies

4. Shell Programming and Scripting

Prevent wrong user from using shell script for multiple remote servers

Hi, I am running a shell script from a central server to multiple remote servers using the following code: application_check() { # Linux/UNIX box with ssh key based login SERVERS=`cat /tmp/server-details` # SSH User name USR="user" # create new file > /tmp/abc.log # connect... (2 Replies)
Discussion started by: mystition
2 Replies

5. UNIX for Dummies Questions & Answers

Change user passwords using shell script

Hi, I want to change the password of unix users on a number of servers.My plan was to ssh to all the servers in a shell script and use the passwd command. I tried to do so but everytime i run it i get this error. ssh -x -n -l user1 host passwd Changing password for "user1" 3004-709 Error... (3 Replies)
Discussion started by: poojabhat
3 Replies

6. Shell Programming and Scripting

Shell script to change the password on multiple servers in linux

Can any one please let me know the shell script to change the password for a particular user on multiple linux servers. (2 Replies)
Discussion started by: s_madras
2 Replies

7. UNIX for Dummies Questions & Answers

Unable to change domain user passwords

Hi, I'm new to this site, so my apologies if this is posted to the wrong board. I'm the student administrator of a small computer science lab (20 Win 7 PCs) at a university. The logins to the PCs are handled by samba (v. 3.5.8) on a CentOS server (kernel v. 2.6.9-100.ELsmp). Recently I ... (1 Reply)
Discussion started by: kerona
1 Replies

8. Shell Programming and Scripting

How to change passwords for User accounts on multiple UNIX/Linux machines remotely?

Hello Experts, Need some direction on creating shell script for following environment: We have about 20 people in the team working as Oracle DBA's (sysdba's and appdba's). Total Servers which is a mix of Unix and Linux are 200. We do not have Root user access on any of the servers and... (3 Replies)
Discussion started by: sha2402
3 Replies

9. Shell Programming and Scripting

Shell script to ssh and change the passwords

Hi All, I am trying to create a script with the help of while and expect loop to do the following: 1. script will pick up the servers one by one from server_list file and will do ssh to it. 2. for each server it will change the password of user test1. 3. script should also provide logs for... (1 Reply)
Discussion started by: omkar.jadhav
1 Replies

10. Shell Programming and Scripting

Script To Delete User Accounts On Multiple Servers

Hello All, The servers in question are AIX/Unix servers. I was hoping to find a scripting solution where I could use one server as a jump server and run a script that would check each server for a user account (the source file for the user accounts would be a text file or csv file) , and delete... (4 Replies)
Discussion started by: k45bryant
4 Replies
pssh(1) 						      General Commands Manual							   pssh(1)

NAME
pssh -- parallel ssh program SYNOPSIS
pssh [-vAiIP] [-h hosts_file] [-H [user@]host[:port]] [-l user] [-p par] [-o outdir] [-e errdir] [-t timeout] [-O options] [-x args] [-X arg] command ... pssh -I [-vAiIP] [-h hosts_file] [-H [user@]host[:port]] [-l user] [-p par] [-o outdir] [-e errdir] [-t timeout] [-O options] [-x args] [-X arg] [command ...] DESCRIPTION
pssh is a program for executing ssh in parallel on a number of hosts. It provides features such as sending input to all of the processes, passing a password to ssh, saving output to files, and timing out. OPTIONS
-h host_file --hosts host_file Read hosts from the given host_file. Lines in the host file are of the form [user@]host[:port] and can include blank lines and com- ments (lines beginning with "#"). If multiple host files are given (the -h option is used more than once), then pssh behaves as though these files were concatenated together. If a host is specified specified multiple times, then pssh will connect the given number of times. -H [user@]host[:port] --host [user@]host[:port] -H "[user@]host[:port] [ [user@]host[:port ] ... ]" --host "[user@]host[:port] [ [user@]host[:port ] ... ]" Add the given host strings to the list of hosts. This option may be given multiple times, and may be used in conjunction with the -h option. -l user --user user Use the given username as the default for any host entries that don't specifically specify a user. -p parallelism --par parallelism Use the given number as the maximum number of concurrent connections. -t timeout --timeout timeout Make connections time out after the given number of seconds. With a value of 0, pssh will not timeout any connections. -o outdir --outdir outdir Save standard output to files in the given directory. Filenames are of the form [user@]host[:port][.num] where the user and port are only included for hosts that explicitly specify them. The number is a counter that is incremented each time for hosts that are specified more than once. -e errdir --errdir errdir Save standard error to files in the given directory. Filenames are of the same form as with the -o option. -x args --extra-args args Passes a extra SSH command-line arguments (see the ssh(1) man page for more information about SSH arguments). This option may be specified multiple times. The arguments are processed to split on whitespace, protect text within quotes, and escape with back- slashes. To pass arguments without such processing, use the -X option instead. -X arg --extra-arg arg Passes a single SSH command-line argument (see the ssh(1) man page for more information about SSH arguments). Unlike the -x option, no processing is performed on the argument, including word splitting. To pass multiple command-line arguments, use the option once for each argument. -O options --options options SSH options in the format used in the SSH configuration file (see the ssh_config(5) man page for more information). This option may be specified multiple times. -A --askpass Prompt for a password and pass it to ssh. The password may be used for either to unlock a key or for password authentication. The password is transferred in a fairly secure manner (e.g., it will not show up in argument lists). However, be aware that a root user on your system could potentially intercept the password. -i --inline Display standard output and standard error as each host completes. -v --verbose Include error messages from ssh with the -i and options. -I --send-input Read input and send to each ssh process. Since ssh allows a command script to be sent on standard input, the -I option may be used in lieu of the command argument. -P --print Display output as it arrives. This option is of limited usefulness because output from different hosts are interleaved. EXAMPLE
Connect to host1 and host2, and print "hello, world" from each: pssh -i -H "host1 host2" echo "hello, world" Print "hello, world" from each host specified in the file hosts.txt: pssh -i -h hosts.txt echo "hello, world" Run a command as root with a prompt for the root password: pssh -i -h hosts.txt -A -l root echo hi Run a long command without timing out: pssh -i -h hosts.txt -t 0 sleep 10000 If the file hosts.txt has a large number of entries, say 100, then the parallelism option may also be set to 100 to ensure that the com- mands are run concurrently: pssh -i -h hosts.txt -p 100 -t 0 sleep 10000 Run a command without checking or saving host keys: pssh -i -H host1 -H host2 -x "-O StrictHostKeyChecking=no -O UserKnownHostsFile=/dev/null -O GlobalKnownHostsFile=/dev/null" echo hi EXIT STATUS VALUES
0 Success 1 Miscellaneous error 2 Syntax or usage error 3 At least one process was killed by a signal or timed out. 4 All processes completed, but at least one ssh process reported an error (exit status 255). 5 There were no ssh errors, but at least one remote command had a non-zero exit status. AUTHORS
Written by Brent N. Chun <bnc@theether.org> and Andrew McNabb <amcnabb@mcnabbs.org>. http://code.google.com/p/parallel-ssh/ SEE ALSO
ssh(1), pscp(1), prsync(1), pslurp(1), pnuke(1) February 25, 2010 pssh(1)
All times are GMT -4. The time now is 04:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy