MacOS – Multiple machine ssh client application for macOS

macossshterminal

In Windows there are applications such as mobaexterm that allow the user to control multiple remote ssh clients conveniently. For example, in order to run the same command on multiple machine, or save multiple session (so that it would be easy re-connect to those sessions simultaneously in the future).

Is it possible to achieve this goal from the macOS machine? Are there any relevant applications for this?

Best Answer

Yes, it is possible - there are a number of ways to do this.

You can install the program "csshx" from HomeBrew which is specifically designed for this purpose. First you'll need to have HomeBrew installed, and then run this command to install csshx:

brew install csshx

Then you can run csshx like this:

csshX server1 server2 server3

where serverX should be replaced with the actual hostnames of your servers.

That will display three graphical macOS windows with the output from each of the servers, and a fourth window with a red background, where you enter your commands. These commands are then sent to all three servers.

A different approach is to use "tmux". It is a common application for Terminal usage that have many advantages, and one of them is that it allows parallel execution. In general it allows for having multiple shell sessions within one Terminal tab - for example you can have three shells with connections to different servers each in their own pane, but all in the same macOS window/tab.

Again you'll need to have HomeBrew installed, and then run this command to install:

brew install tmux

You can then run tmux to start the program. Open a pane for each you want to connect to, and ssh into them as you would normally do. When you're ready to execute commands on all servers at once, press Ctrl-B and then:

:setw synchronize-panes

Now everything you write will be written to all the panes.

You need to press Ctrl-B and run:

:setw synchronize-panes off

to disable the feature again.