2

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?

1
  • Have you tried iTerm2?
    – Allan
    Dec 12, 2018 at 13:52

3 Answers 3

2

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.

1

C3 Tools is my top pick https://www.csm.ornl.gov/torc/C3/

PSSH is another tool

Consider if you’re running regular recipes (or: update packages on all systems) to use something like Ansible instead to manage your cluster. More work up front but a repeatable solution.

1

The best option is to use something like Ansible. Install Ansible on your machine and do something similar to the below to achieve your goal.

Instructions:

Setup an inventory of the servers you wish to control:

inventory/hosts.ini

[all]
server1
server2
server3
  • create a file called playbook.yml
---
- hosts: all
   become: yes
   tasks:
   - name: my command i want to execute
   command: ls -l

execute via command line

ansible-playbook -i inventory/hosts.ini playbook.yml -vvvv

the -vvvv will give you some verbose debug info

This is just a flavour of what to do.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .