Parallel SSH with Custom Parameters to Each Host
bash, distributed, linux, shell, ssh
Solution
You could use GNU parallel.
Suppose you have a file argfile:
111.111.111.111 param1a param1b ...
222.222.222.222 param2a param2b ...
Then running
parallel --colsep ' ' ssh {1} prog {2} {3} ... :::: argfile
Would run `prog` on each host with the corresponding parameters. It is important that the number of parameters be the same for each host.
Problem
There are plenty of threads and documentation about parallel ssh, but I can't find anything on passing custom parameters to each host. Using `pssh` as an example, the hosts file is defined as: ``` 111.111.111.111 222.222.222.222 ``` However, I want to pass custom parameters to each host via a shell script, like this: ``` 111.111.111.111 param1a param1b ... 222.222.222.222 param2a param2b ... ``` Or, better, the hosts and parameters would be split between 2 files. Because this isn't common, is this misuse of parallel ssh? Should I just create many ssh processes from my script? How should I approach this?