Install Parallel SSH to connect to multiple hosts.
[1] Install PSSH.
Install Parallel SSH to connect to multiple hosts.
[1] Install PSSH.
[2] How to use 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
[cent@host ~]$ pssh -H "10.0.0.51 10.0.0.52" -i "hostname"
[1] 17:28:02 [SUCCESS] 10.0.0.51
node01.local
[2] 17:28:02 [SUCCESS] 10.0.0.52
node02.local
# it's possible to read host list fron a file
[cent@localhost ~]$ vi pssh_hosts.txt
# write hosts per line like follows
cent@10.0.0.51
cent@10.0.0.52
[cent@localhost ~]$ pssh -h pssh_hosts.txt -i "uptime"
[1] 19:37:59 [SUCCESS] cent@10.0.0.52
19:37:59 up 1:35, 0 users, load average: 0.00, 0.00, 0.00
[2] 19:37:59 [SUCCESS] cent@10.0.0.51
19:37:59 up 1:35, 0 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@localhost ~]$ 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] 12:54:06 [SUCCESS] cent@10.0.0.51
2.6.32-504.12.2.el6.x86_64
[2] 12:54:06 [SUCCESS] cent@10.0.0.52
2.6.32-504.12.2.el6.x86_64
[4] By the way, PSSH package includes pscp.pssh, prsync, pslurp, pnuke commands and you can use them with the same usage of pssh.