OpenSSH : Use Parallel SSH2024/12/19 |
Use PSSH (Parallel Secure Shell) to connect to multiple hosts via SSH. |
|
[1] | Install PSSH. |
# install from EPEL [root@dlp ~]# dnf --enablerepo=epel -y install pssh
|
[2] | Basic usage for PSSH. 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 and access via SSH [cent@dlp ~]$ pssh -H "10.0.0.51 10.0.0.52" -i "hostname" [1] 13:17:26 [SUCCESS] 10.0.0.52 node02.srv.world [2] 13:17:26 [SUCCESS] 10.0.0.51 node01.srv.world # write a host per line like follows cent@10.0.0.51 cent@10.0.0.52 pssh -h pssh_hosts.txt -i "uptime" [1] 13:18:47 [SUCCESS] cent@10.0.0.51 13:18:47 up 2:33, 4 users, load average: 0.00, 0.00, 0.00 [2] 13:18:47 [SUCCESS] cent@10.0.0.52 13:18:47 up 7 min, 4 users, load average: 0.00, 0.00, 0.00 |
[3] | It's possible to connect with password authentication too, but it needs passwords on all hosts are the same one. |
[cent@dlp ~]$ pssh -h pssh_hosts.txt -A -O PreferredAuthentications=password -i "uname -r"
Warning: do not enter your password if anyone else has superuser
privileges or access to your account.
Password: # input password
[1] 13:19:28 [SUCCESS] cent@10.0.0.51
6.12.0-32.el10.x86_64
[2] 13:19:28 [SUCCESS] cent@10.0.0.52
6.12.0-32.el10.x86_64
|
[4] |
PSSH package includes pscp.pssh, prsync, pslurp, pnuke commands and you can use them with the same usage of pssh.
|
Sponsored Link |
|