Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

3 Answers 3

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

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.