Run the same command in several servers with SSH from MacOSX

Solution 1:

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

Solution 2:

tmux-cssh is worth trying:

brew install tmux-cssh
tmux-cssh -u user host1 host2 host3 host4 host5

2019-12-19 Update

As noted in the comments, tmux-cssh is no longer installable from homebrew. But anyway, it’s actually just a relatively simple shell script, and you get it from here:

https://raw.githubusercontent.com/peikk0/tmux-cssh/master/tmux-cssh

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

tiled view of simultaneous ssh connections to 5 hosts in tmux-cssh


Solution 3:

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.


Solution 4:

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.


Solution 5:

I ended up using csshX:

alt text

Tags:

Ssh

Mac Osx