Is there some program to run the same command in several servers with SSH from MacOSX?
7 Answers
iTerm2 can do it. Create one bookmark per server and set the command for each bookmark to ssh . Then use the 'send input to all tabs' feature. You can open a bunch of bookmarks at once using the bookmarks window (cmd-m). https://iterm2.com/index.html
-
1Just to update everyone, iTerm2 has a new URL :) http://iterm2.com/ – Tmanok Apr 04 '17 at 03:42
https://github.com/peikk0/tmux-cssh is worth trying. Not brew-installable, but it’s just a simple shell script at https://raw.githubusercontent.com/peikk0/tmux-cssh/master/tmux-cssh — so do:
curl -O https://raw.githubusercontent.com/peikk0/tmux-cssh/master/tmux-cssh
chmod 755 tmux-cssh
./tmux-cssh -u user host1 host2 host3 host4 host5

- 206
- 2
- 7
-
1It appears to have been removed from brew `Error: No available formula with the name "tmux-cssh"` – spuder Dec 18 '19 at 17:07
Take a look at ClusterSSH. I have used this to great effect from an OSX 10.5 workstation, but cannot verify that it works correctly from 10.6. I highly suspect it should work fine.

- 14,907
- 10
- 53
- 83
I ended up using csshX:

- 7,438
- 25
- 71
- 83
-
1I think iTerm2 and Command+Shift+I on multiple panes is a better option now. I have tried both. – Ryan Oct 01 '18 at 06:00
There are a number of tools for doing this. One example is Parallel SSH. It looks like you have to compile it from source for macos but it should seve as a good starting point.
This linux.com article has a good description of how pssh works. Also, the comments on that story cover other alternatives like Capistrano. I used to use Tentakel for this purpose but it looks like that project has gone dead.
Note that a lot of the tasks you might want to automate with a parallel ssh tool are really good candidates for automation with a configuration management tool like puppet or chef or cfengine.

- 14,947
- 4
- 35
- 52
-
ha I think some of us are giving the 'big answer' solutions and some the quick expedient answer solutions. – Phil Hollenback Jan 12 '11 at 19:15
I think iTerm can do this (iterm.sf.net)

- 11,178
- 1
- 37
- 50
-
It can't send the same input to all tabs, but not establish the connections automatically, as far as I know. – Pablo Fernandez Jan 12 '11 at 18:40
You could use any number of ssh multiplexers: e.g., dsh (dancer shell), pdsh. Check MacPorts.
Or, perhaps somewhat more simply: for x in $( cat hosts.txt ); do ssh $x ; done
More complicated things, like Chef's knife, Capistrano, func, or helm, also exist.

- 164
- 5