Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hi I'm looking for a piece of software or some sort of technique that would enable me to do following in one terminal window:

  • Take as input a list of ssh-enabled machines with login, password and script path information, something like this:

    login:pass@192.168.1.1/path/to/script/run.sh login:pass@192.168.1.2/path/to/script/run.sh

  • Open ssh connections to these machines and run the specified scripts remotely.

  • Output from all the scripts should be piped to my local window.
  • When I send a signal like Ctrl-C, I want to kill the remote scripts and then the connection. A massive plus would be if my machine goes down, the remote scripts are killed also.

A plus would be if I could use this in Cygwin terminal since that's what I use, but I'm open to anything that would get this done.

share|improve this question

I assume you're using OpenSSH. It is deliberately difficult to programatically give a password to ssh, because it's typically a bad idea. Instead of using passwords, can you use public key authentication? If so, the following should do the trick:

for cmd in login@192.168.1.1:/path/to/script/run.sh login@192.168.1.2:/path/to/script/run.sh; do
    ssh ${cmd%%:*} ${cmd#*:}
done
share|improve this answer
    
That would, actually, be one of those moments were something like GNU parallel might be handy. – Bobby May 10 '13 at 11:17

You will need public key authentication, you will also need something like PSSH which is a python based tool for running multiple parallel ssh sessions.

https://code.google.com/p/parallel-ssh/

share|improve this answer

If you can write Perl, you should check Net::OpenSSH::Parallel.

It can log in the remote hosts using public key or password authentication and run the programmed tasks in parallel.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .