Automated ssh to multiple boxes


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Automated ssh to multiple boxes
# 1  
Old 09-24-2008
Automated ssh to multiple boxes

I have a script that will ssh to several different servers, perform a command, display the output, and exit. It works well, but I have to enter my password for each server. That gets a little cumbersome when you have a couple dozen servers. Anyone out there know how to automate this so that I only have to enter my password once? Here's the script like what I'm currently using...

Code:
#!/usr/bin/env  ksh -p
  
 getLogin()
  { 

    stty  -echo
    read  pwd?'Please enter your production password: '
    stty  echo
     echo
  
    return  0
 }
  
 getLogin
 ssh  user@server1 'ls  /path/resubmit'
 ssh  user@server2 'ls  /path/resubmit'
 ssh  user@server3 'ls  /path/resubmit'
 ssh  user@server4 'ls  /path/resubmit'

# 2  
Old 09-25-2008
Use ssh-agent, or set up keys with empty passwords.
# 3  
Old 09-25-2008
You could use cssh to do that (SourceForge.net: cssh). Very useful for doing work on many servers at once.
Otherwise I'd do as era suggests.

As a final option, you could use 'expect' to send the password to ssh each time (that's kind of ugly though)
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need a script to scp a file to multiple boxes

Hello All, I am new to scripting and I am trying to write a script which can scp a file from one box to multiple boxes. I am thinking to do like this. 1) create a file with list of all server names 2)write a script which will pick up each server line by line from server list and copy it to... (1 Reply)
Discussion started by: sintilash
1 Replies

2. Shell Programming and Scripting

Shell script to login into multiple linux boxes

I have requirement to login into a multiple linux boxes by running the shell script in a single linux box and to find the count of files in a specific folder in each box and log them in a log file in the box where i m runnning the script. Box names will be stored in a text file host.txt. Please... (2 Replies)
Discussion started by: Mani2512
2 Replies

3. Shell Programming and Scripting

automated ssh with provision for passphrase

Below is a part of my shell script. Currently I have shared the public key of the client with the host, therefore I will not be prompted for the password. The key that has been created on the client is also without a passphrase. If it is created with a passphrase, the code I have will not... (3 Replies)
Discussion started by: farahzaiba
3 Replies

4. Shell Programming and Scripting

Automated script to SSH to another server

Hi guys, I have a script which looks a little like this; grep $id /usr/local/production/service/distributor/clients/*/out/events.xml | awk -F/ '{print $8}' I want to be able to run this on my dev box, so need to add something into the script which will SSH onto the live server, collect the... (2 Replies)
Discussion started by: JayC89
2 Replies

5. UNIX for Dummies Questions & Answers

Virtualbox OSE on multiple boxes

I have Virtualbox OSE installed on my laptop and soon on my lap top. My question is if I were to make a virtual os on an external hard drive on my laptop, can i make a settings to use the same vdi on my desktop and have it show the same screen, not at the same time. sorry, its late here and I... (0 Replies)
Discussion started by: Texasone
0 Replies

6. IP Networking

Automated ftp for Multiple files

I have seen the script posted yesterday for automated ftp Can we do some thing like ftp ing multiple files in one script Example input.txt has all files names to be ftped input.txt ------ a.tar b.ccp c.perl i need to ftp all the files present in input.txt i tried something like... (0 Replies)
Discussion started by: pbsrinivas
0 Replies

7. Shell Programming and Scripting

I need a Script to rsh multiple hp boxes and shutdown

Hello I'm serving on a ship that has frequent power issues. Currently if we loose power we need to rush around to multiple UNIX machines and login to Sysadmin and power down each machine before we loose our ups. If sysadmin is asleep or not in the space we have some real problems. I would like to... (2 Replies)
Discussion started by: blackfam972
2 Replies

8. UNIX for Dummies Questions & Answers

Getting one script to run on multiple boxes

I have a script that generates an output file after pulling data from a local DB on one of my boxes. There are other nearly-identical boxes on the network, each with their own local DB, and I'd like to run the script there too. Copying the script to each box and then running them individually... (11 Replies)
Discussion started by: bschnair
11 Replies

9. Programming

text boxes, radio buttons , check boxes in c++ on unix

Hi ! Please tell me how to get radio buttons, text boxes , check boxes , option buttons , pull down menus in C++ on Unix. I think it would be done using curses.h ..but that's all i know. TIA, Devyani. (3 Replies)
Discussion started by: devy8
3 Replies
Login or Register to Ask a Question