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

2021-12-30 Thread Andy Smith
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



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

2021-12-30 Thread Marco Möller

On 30.12.21 16:42, Andy Smith wrote:


On Thu, Dec 30, 2021 at 05:15:18PM +0200, Anssi Saari wrote:

Marco Möller  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.



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



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

2021-12-30 Thread Nicholas Geovanis
On Thu, Dec 30, 2021, 9:42 AM Andy Smith  wrote:

> Hello,
>
> On Thu, Dec 30, 2021 at 05:15:18PM +0200, Anssi Saari wrote:
> > Marco Möller  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
>
>


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

2021-12-30 Thread Andy Smith
Hello,

On Thu, Dec 30, 2021 at 05:15:18PM +0200, Anssi Saari wrote:
> Marco Möller  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



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

2021-12-30 Thread Anssi Saari
Marco Möller  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.



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

2021-12-30 Thread Charles Curley
On Thu, 30 Dec 2021 14:54:40 +0100
Marco Möller  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/



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

2021-12-30 Thread Celejar
On Thu, 30 Dec 2021 14:54:40 +0100
Marco Möller  wrote:

> 
> 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?

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