Use clusterssh: https://sourceforge.net/projects/clusterssh/
To execute commands in parallel, you use it like
cssh user@client1 user@client2
This you get a terminal window for each client and a commandwindow to type commands on any terminal in parallel.
There are many options to set inside ~/.clusterssh directory, so it is easy to group your clients by tags.
To bundle clients from your host.txt
, the file ~/.clusterssh/tags
may look like this:
root@host1 tar update
root@host2 tar update
root@host3 tar test
root@host4 update test
root@host5 update test
This way you define the tags tar, update and test. You can use the tag tar
to run clusterssh on the first three hosts by running cssh tar
.
Search the internet for clusterssh
and you'll find a lot of helpful docs.
Most linux distros contain clusterssh so you may install it easily by e.g. apt-get install clusterssh
.
Edit:
You may add your command to clusterssh to be executed use the -a
option:
cssh tar -a "tar -cvf /tmp/TC.tar.gz /etc"
And if you use ssh public/private keys, you don't have to type the password all the time ...