8

Is there some program to run the same command in several servers with SSH from MacOSX?

Pablo Fernandez
  • 7,438
  • 25
  • 71
  • 83

7 Answers7

10

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

user66808
  • 201
  • 1
  • 2
6

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

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

sideshowbarker
  • 206
  • 2
  • 7
  • 1
    It appears to have been removed from brew `Error: No available formula with the name "tmux-cssh"` – spuder Dec 18 '19 at 17:07
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.

Scott Pack
  • 14,907
  • 10
  • 53
  • 83
3

I ended up using csshX:

alt text

Pablo Fernandez
  • 7,438
  • 25
  • 71
  • 83
  • 1
    I 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
2

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.

Phil Hollenback
  • 14,947
  • 4
  • 35
  • 52
0

I think iTerm can do this (iterm.sf.net)

jj33
  • 11,178
  • 1
  • 37
  • 50
0

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.

bdha
  • 164
  • 5