OpenSSH : Use Parallel SSH2021/07/19 |
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. |
node01.srv.world
node02.srv.world # run [uname] command to target hosts [rocky@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 "rocky" [*] spawning 2 parallel ssh sessions node01.srv.world -> Linux node01.srv.world 4.18.0-305.3.1.el8_4.x86_64 #1 SMP Wed Jul 5 02:00:39 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux node02.srv.world -> Linux node02.srv.world 4.18.0-305.3.1.el8_4.x86_64 #1 SMP Wed Jul 5 02:00:39 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux Done. 2 hosts processed. # output result per host [rocky@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 "rocky" [*] blind mode enabled [*] using output directory : ./output [*] spawning 2 parallel ssh sessions Done. 2 hosts processed.[rocky@dlp ~]$ ll ./output total 8 -rw-r--r--. 1 rocky rocky 1236 Jul 13 15:04 rocky@node01.srv.world.out -rw-r--r--. 1 rocky rocky 1183 Jul 13 15:04 rocky@node02.srv.world.out[rocky@dlp ~]$ cat ./output/rocky@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 ..... ..... |
Sponsored Link |
|