CentOS Stream 8
Sponsored Link

OpenSSH : Use Parallel SSH2021/02/22

 
Use MPSSH (Mass Parallel Secure Shell) to connect to multiple hosts via SSH.
[1] Install MPSSH.
# install from EPEL

[root@dlp ~]#
dnf --enablerepo=epel -y install mpssh
[2] Basic usage for MPSSH.
This is based on the environment you set SSH key-pair to target Hosts without passphrase.
If set passphrase, run SSH-Agent and set passphrase on it first.
# specify target hosts per line

[cent@dlp ~]$
vi ssh_targets
node01.srv.world
node02.srv.world
# run [uname] command to target hosts

[cent@dlp ~]$
mpssh -f ssh_targets "uname -a"

MPSSH - Mass Parallel Ssh Ver.1.3.3

  [*] read (2) hosts from the list
  [*] executing "uname -a" as user "cent"
  [*] spawning 2 parallel ssh sessions

node01.srv.world -> Linux node01.srv.world 4.18.0-240.el8.x86_64 #1 SMP Wed Feb 5 02:00:39 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
node02.srv.world -> Linux node02.srv.world 4.18.0-240.el8.x86_64 #1 SMP Wed Feb 5 02:00:39 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

  Done. 2 hosts processed.

# output result per host

[cent@dlp ~]$
mpssh -b -o ./output -f ssh_targets "cat /etc/passwd"

MPSSH - Mass Parallel Ssh Ver.1.3.3

  [*] read (2) hosts from the list
  [*] executing "cat /etc/passwd" as user "cent"
  [*] blind mode enabled
  [*] using output directory : ./output
  [*] spawning 2 parallel ssh sessions

  Done. 2 hosts processed.

[cent@dlp ~]$
ll ./output

total 8
-rw-r--r--. 1 cent cent 1236 Feb 13 15:04 cent@node01.srv.world.out
-rw-r--r--. 1 cent cent 1183 Feb 13 15:04 cent@node02.srv.world.out

[cent@dlp ~]$
cat ./output/cent@node01.srv.world.out

root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
.....
.....
Matched Content