1

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.

3 Answers 3

0

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

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/

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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