There is a list of IP addresses in a .txt file, ex.:
18.104.22.168 22.214.171.124 126.96.36.199
Behind every IP address there is a server, and on every server there is an sshd running on port 22. Not every server is in the
known_hosts list (on my PC, Ubuntu 10.04 LTS/bash).
How can I run commands on these servers, and collect the output?
Ideally, I'd like to run the commands in parallel on all the servers.
I'll be using public key authentication on all the servers.
Here are some potential pitfalls:
- The ssh prompts me to put the given servers ssh key to my
- The given commands might return a nonzero exit code, indicating that the output is potentially invalid. I need to recognize that.
- A connection might fail to be established to a given server, for example because of a network error.
- There should be a timeout, in case the command runs for longer than expected or the server goes down while running the command.
The servers are AIX/ksh (but I think that doesn't really matter.