Sponsored Content
Top Forums Shell Programming and Scripting A script to change password for all other servers Post 302992098 by Hiroshi on Tuesday 21st of February 2017 02:48:50 PM
Old 02-21-2017
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 testing the script with a test data file with about 5 servers in it. The data file is the command-line argument to the script. Can you please tell me what's wrong and how to fix it?

As always, I truly appreciate this community effort. You guys are truly awesome; thank you very much.
Code:
#!/bin/bash
##data file name is passed in as argument to .sh script
filename="$1"
while  read -r line
do
        ##newPassword and username are placeholders
        ssh $line 'echo -e "TestPW\nTestPW" | passwd SomeUser'
done < "$filename"


Last edited by vbe; 02-21-2017 at 04:03 PM.. Reason: code tags please
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to script to logon servers using id and password

Hey.. I am new in scripting.. I know a little bit of scripting.. I am facing some problem.. I need to create a script using which I may log on to a server (e.g. ftp) with ID and password.. thus copy a particular file to a local dir.. the commands required to do that I do know.. I am able to do it... (1 Reply)
Discussion started by: razeeev
1 Replies

2. Shell Programming and Scripting

script to change passwords for the same user on multiple servers

I am trying to write a script to change passwords for the same user on multiple servers. My environment runs purely ssh / scp not rsh / rcp and therefore coping using rcp is not an option. I have been playing with expect to perform tasks but think there must be a better way. Has anyone got... (7 Replies)
Discussion started by: stolz
7 Replies

3. 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

4. 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

5. 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

6. Solaris

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 (1 Reply)
Discussion started by: vickyingle5
1 Replies

7. 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

8. Shell Programming and Scripting

Script for login to servers with user name and password and execute commands

I am having the 15 servers which need to do the monitoring Hi I need a shell script, By which i can log in to multiple servers and execute the commands.. I need to specify the username and password in the scripts. Please help me to write the script so that it can login with username and... (5 Replies)
Discussion started by: nandan8a
5 Replies

9. AIX

How to write a script to run without password on a batch of servers?

I need run a command such as ps -ef |grep xxx on a batch of servers, how to write a script to run it without password? don't need go in each server to check? Thanks (7 Replies)
Discussion started by: rainbow_bean
7 Replies

10. Shell Programming and Scripting

Shell script to set user password to never expire in UNIX servers

Hi, I have a requirement where in i need to write a shell script to set users password to never expire. I know the command which is used to perform the same .. which is chage command. But, could not figure out how to do the same in shell script. Could you please help me with the shell... (3 Replies)
Discussion started by: suren424
3 Replies
SETUP-DS.PL(8)						      System Manager's Manual						    SETUP-DS.PL(8)

NAME
setup-ds.pl - Set up an instance of Directory Server SYNOPSIS
setup-ds.pl [--options] -- [args] DESCRIPTION
Set up a Directory Server instance. Creates the configuration files for an instance of Directory Server based on a few parameters like the hostname, port number, and directory manager information. Can be run in interactive mode with different levels of verbosity, or in silent mode with parameters supplied in a .inf format file or on the command line. OPTIONS
A summary of options is included below: --help This message --version Print the version and exit --debug Turn on debugging --silent Use silent setup - no user input --file=name Use the file 'name' in .inf format to supply the default answers --keepcache Do not delete the temporary .inf file generated by this program --logfile Log setup messages to this file - otherwise, a temp file will be used --update Update existing installations - add/update schema files, add/change configuration, add new instance scripts, etc. You must run set- up-ds.pl -u after upgrading your packages. You will usually have to restart your servers in order for all of the changes to take effect (e.g. adding/changing plug-in configuration), so schedule this when you can afford a little downtime. --continue (Update only) Keep going even if errors occur. You will usually not need to use this option unless your installation is broken and you need to force it to update in order to fix it. For all options, you can also use the short name e.g. -h, -d, etc. For the -d argument, specifying it more than once will increase the debug level e.g. -ddddd args: You can supply default .inf data in this format: section.param=value e.g. General.FullMachineName=foo.example.com or "slapd.Suffix=dc=example, dc=com" Values passed in this manner will override values in an .inf file given with the -f argument. UPDATES
The update process (setup-ds.pl -u) can work in one of two modes: Online: Configuration changes are made to the running directory servers using LDAP. The operations must be performed as an administrative user. You must provide the name and password, for each instance if there is more than one instance of directory server. Some changes (e.g. plug-ins) may require a directory server restart to take effect. The update script will notify you if a restart is required. Offline: The changes are made to the server configuration files. The servers MUST FIRST BE SHUTDOWN BY YOU. The script will not shutdown the servers for you. You MUST shutdown the servers in order to use this mode. A username and password are not required to use Offline mode. If the servers are not shutdown, CHANGES WILL BE LOST. To summarize: Online - servers remain running - you must provide admin name and password for each server - servers may need to be restarted Offline - servers must be shutdown - no username or password required AUTHOR
setup-ds.pl was written by the 389 Project. REPORTING BUGS
Report bugs to http://bugzilla.redhat.com. COPYRIGHT
Copyright (C) 2008 Red Hat, Inc. This manual page was written by Michele Baldessari <michele@pupazzo.org>, for the Debian project (but may be used by others). This is free software. You may redistribute copies of it under the terms of the Directory Server license found in the LICENSE file of this software distribution. This license is essentially the GNU General Public License version 2 with an exception for plug-in distribution. May 18, 2008 SETUP-DS.PL(8)
All times are GMT -4. The time now is 07:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy