OpenSSH : Use Parallel SSH2026/04/24 |
|
Install Parallel SSH to connect to multiple hosts. |
|
| [1] | Install PSSH. |
|
root@dlp:~# apt -y install pssh
|
| [2] | This is the basic usage for PSSH. This is the case for key-pair authentication without passphrase. If passphrase is set in key-pair, start SSH-Agent first to automate inputting passphrase. |
|
# connect to hosts and execute [hostname] command ubuntu@dlp:~$ parallel-ssh -H "10.0.0.51 10.0.0.52" -i "hostname" [1] 07:59:56 [SUCCESS] 10.0.0.52 node02.srv.world [2] 07:59:56 [SUCCESS] 10.0.0.51 node01.srv.world # it's possible to read host list from a file
ubuntu@dlp:~$
vi pssh_hosts.txt # write hosts per line like follows ubuntu@10.0.0.51 ubuntu@10.0.0.52 parallel-ssh -h pssh_hosts.txt -i "uptime" [1] 08:00:37 [SUCCESS] ubuntu@10.0.0.52 08:00:37 up 2 min, 1 user, load average: 0.06, 0.08, 0.03 [2] 08:00:37 [SUCCESS] ubuntu@10.0.0.51 08:00:37 up 20 min, 2 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. |
|
ubuntu@dlp:~$ parallel-ssh -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] 08:01:10 [SUCCESS] ubuntu@10.0.0.51
7.0.0-14-generic
[2] 08:01:10 [SUCCESS] ubuntu@10.0.0.52
7.0.0-14-generic
|
| [4] |
By the way, PSSH package includes [parallel-scp], [parallel-rsync], [parallel-slurp], [parallel-nuke] commands and you can use them with the same usage of pssh.
|
| Sponsored Link |
|
|