Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[OT] sending command to multiple SSH sessions, like in mRemoteNG

1,041 views
Skip to first unread message

Marco Möller

unread,
Dec 30, 2021, 9:00:04 AM12/30/21
to

In search for a software recommendation:
The remote session management app "mRemoteNG" for MS Windows comes with
a functionality by which a command can be entered to its "Multi SSH"
input field, and this command is then sent to all SSH connected remote
systems at once as if the command would have been typed in at each
single of the SSH connected remote systems CLI individually.
Do you know about such feature to be implemented in some Linux tool?
Maybe it even exists as a plugin for tmux?
Best wishes, Marco.

Celejar

unread,
Dec 30, 2021, 9:20:05 AM12/30/21
to
I'm not sure about tools that send commands to multiple hosts already
connected over SSH, but there are some that are designed to execute the
same command on multiple hosts by initiating SSH connections to them,
such as pssh and clusterssh:

https://code.google.com/archive/p/parallel-ssh/
https://linux.die.net/man/1/pssh

https://github.com/duncs/clusterssh

https://unix.stackexchange.com/questions/505159/how-to-run-the-same-command-on-multiple-servers
https://www.tecmint.com/run-commands-on-multiple-linux-servers/
https://unix.stackexchange.com/questions/19008/automatically-run-commands-over-ssh-on-many-servers

Celejar

Charles Curley

unread,
Dec 30, 2021, 9:40:05 AM12/30/21
to
On Thu, 30 Dec 2021 14:54:40 +0100
Marco Möller <ta...@debianlists.mobilxpress.net> wrote:

> Do you know about such feature to be implemented in some Linux tool?

Take a look at mssh.

--
Does anybody read signatures any more?

https://charlescurley.com
https://charlescurley.com/blog/

Anssi Saari

unread,
Dec 30, 2021, 10:20:04 AM12/30/21
to
Marco Möller <ta...@debianlists.mobilxpress.net> writes:

> The remote session management app "mRemoteNG" for MS Windows comes
> with a functionality by which a command can be entered to its "Multi
> SSH" input field, and this command is then sent to all SSH connected
> remote systems at once as if the command would have been typed in at
> each single of the SSH connected remote systems CLI individually.
> Do you know about such feature to be implemented in some Linux tool?
> Maybe it even exists as a plugin for tmux?

I do simple stuff with just a for loop in the shell. For more complex
stuff I use Ansible which uses ssh internally.

Andy Smith

unread,
Dec 30, 2021, 10:50:05 AM12/30/21
to
Hello,

On Thu, Dec 30, 2021 at 05:15:18PM +0200, Anssi Saari wrote:
> Marco Möller <ta...@debianlists.mobilxpress.net> writes:
> > this command is then sent to all SSH connected remote systems at
> > once as if the command would have been typed in at each single
> > of the SSH connected remote systems CLI individually. Do you
> > know about such feature to be implemented in some Linux tool?
>
> I do simple stuff with just a for loop in the shell. For more complex
> stuff I use Ansible which uses ssh internally.

Aside from shell loops, I've also in the past used dsh which is
still packaged in Debian:

http://www.netfort.gr.jp/~dancer/software/dsh.html

…but these days I also switched to using Ansible ad hoc commands and
playbooks for anything I do repeatedly. Well worth looking into.

Cheers,
Andy

Nicholas Geovanis

unread,
Dec 30, 2021, 11:40:05 AM12/30/21
to
On Thu, Dec 30, 2021, 9:42 AM Andy Smith <an...@strugglers.net> wrote:
Hello,

On Thu, Dec 30, 2021 at 05:15:18PM +0200, Anssi Saari wrote:
> Marco Möller <ta...@debianlists.mobilxpress.net> writes:
> > this command is then sent to all SSH connected remote systems at
> > once as if the command would have been typed in at each single
> > of the SSH connected remote systems CLI individually. Do you
> > know about such feature to be implemented in some Linux tool?
>
> I do simple stuff with just a for loop in the shell. For more complex
> stuff I use Ansible which uses ssh internally.

Aside from shell loops, I've also in the past used dsh which is
still packaged in Debian:

    http://www.netfort.gr.jp/~dancer/software/dsh.html

Other similar options are pdksh, public domain Korn shell. Which is available in Debian repositories for some releases. And the dsh command on IBM's aix unix-ish OS :-) So with NIM support :-) looking like rsh.

…but these days I also switched to using Ansible ad hoc commands and
playbooks for anything I do repeatedly. Well worth looking into.

The same can be said of the salt utility. Supported at cost by Saltstack if necessary. But IMO not the same use-case that the OP intended. One salt contributor some time ago was managing more than 10K servers with it, I only had a few hundred.


Cheers,
Andy

Marco Möller

unread,
Dec 30, 2021, 12:00:05 PM12/30/21
to
I understand from your answer that with Ansible it will be possible to
send commands to various destinations, and on its website (which I
quickly have had a look at) it claims, that it is good for repeating
several command long tasks. Right?

As my aim is to interactively run the same commands on several machines,
in order to observe if they everywhere behave the same or what different
results they would produce, does each SSH session report back to Ansible
the console output of the command, or allow interactivity with the
session like answering questions at the console if the command would
produce a question, as tmux allows such interactivity? Or is Ansible
thought to send non-interactive commands which are supposed to not write
output back to a visible console?

Maybe I specify better what I want to do: for educational or for
diagnostic purpose or for developing and testing a script, I would like
to run a same command on various Linux systems, which have different
configurations, and to then observe at the various consoles the result
of it. So, the Ansible feature for handling repetitive tasks is for sure
nice, but for me it is more of interest to write a command once and to
observe its behavior multiple times, also after having sent the command
once to all sessions to then interactivity follow up in each individual
session where needed.

To everybody thanks to all the interesting feedback already provided,
also in the parallel to his sub-thread answers!
Marco

Andy Smith

unread,
Dec 30, 2021, 12:10:04 PM12/30/21
to
Hi Marco,

On Thu, Dec 30, 2021 at 05:49:38PM +0100, Marco Möller wrote:
> As my aim is to interactively run the same commands on several machines, in
> order to observe if they everywhere behave the same or what different
> results they would produce, does each SSH session report back to Ansible the
> console output of the command, or allow interactivity with the session like
> answering questions at the console if the command would produce a question,
> as tmux allows such interactivity? Or is Ansible thought to send
> non-interactive commands which are supposed to not write output back to a
> visible console?

While dsh or Ansible ad-hoc commands would report back the output,
Ansible won't work for / isn't designed for interactive use and it
would be quite awkward in dsh too. Wouldn't work for full terminal
applications and the like. So config management, ssh multilaunchers
and shell loops aren't the right topol for this.

If all you want to do is launch the same command everywhere, it's
pretty simple in tmux. Get all your logins in different panels and
then synchronize them so the same command is launched in all. Then
unsync to go through and interact individually again.

https://stackoverflow.com/questions/16325449/how-to-send-a-command-to-all-panes-in-tmux

Basically you are wanting a scriptable full terminal, so tmux fits
the bill I think. You can remote control it from outside in many
ways to get it to do what you want.

Cheers,
Andy

--
https://bitfolk.com/ -- No-nonsense VPS hosting

Marco Möller

unread,
Dec 30, 2021, 3:30:05 PM12/30/21
to
On 30.12.21 18:04, Andy Smith wrote:
I have had a first look to the suggested thread at stackoverflow and
will try it out. It sounds very good, very promising, targeting my needs
and I assume it to work well!

Thanks a lot, and best wishes!
Marco

Marco Möller

unread,
Dec 30, 2021, 4:20:04 PM12/30/21
to
Many great suggestions! It took me some time to follow all suggested
links. Spontaneously it appears to me that clusterssh would best fit my
special needs, and this tool would compete with the tmux functionality
to synchronize panes when needed, as mentioned in one of the linked
threads and then also suggested by Andy. I will test both options.
Thanks a lot for your great help, and best wishes,
Marco

Marco Möller

unread,
Dec 30, 2021, 4:40:04 PM12/30/21
to
On 30.12.21 15:06, Charles Curley wrote:
> On Thu, 30 Dec 2021 14:54:40 +0100
> Marco Möller <ta...@debianlists.mobilxpress.net> wrote:
>
>> Do you know about such feature to be implemented in some Linux tool?
>
> Take a look at mssh.
>

I will test it, although I spontaneously from reading do not expect it
to be as comfortable as tmux with its synchronize panes functionality or
clusterssh. However, a real test and figuring out how to properly make
use this tool might surprise me!
Thanks a lot, and best wishes,
Marco

Marco Möller

unread,
Dec 30, 2021, 4:40:05 PM12/30/21
to
On 30.12.21 17:38, Nicholas Geovanis wrote:
> Aside from shell loops, I've also in the past used dsh which is
> still packaged in Debian:
>
> http://www.netfort.gr.jp/~dancer/software/dsh.html
> <http://www.netfort.gr.jp/~dancer/software/dsh.html>
>
>
> Other similar options are pdksh, public domain Korn shell. Which is
> available in Debian repositories for some releases. And the dsh command
> on IBM's aix unix-ish OS :-) So with NIM support :-) looking like rsh.
>
> …but these days I also switched to using Ansible ad hoc commands and
> playbooks for anything I do repeatedly. Well worth looking into.
>
>
> The same can be said of the salt utility. Supported at cost by Saltstack
> if necessary. But IMO not the same use-case that the OP intended. One
> salt contributor some time ago was managing more than 10K servers with
> it, I only had a few hundred.

I'll keep these tools in mind for some possible future usage. Right now
they seem to not exactly be what I was searching for, but obviously my
initial question was lacking a proper description of my aspired usage
scenario, especially the wish to keep sessions running interactively
while also sending ad hoc commands simultanously to all these sessions.
Your answer is much appreciated, thanks a lot for it, and best wishes!
Marco
0 new messages