參考網頁: 
CentOS 7 : SSH Server : Use Parallel SSH : Server World 
如果有多台 Server 要查看或進行設定,可以考慮使用 pssh。 
使用限制: 
這幾台 Server 的密碼要一樣,或是先好 頭城國小資訊組 | 免密碼登入 SSH Server 的設定。 
1. 安裝 pssh 
# yum install pssh –enablerepo=epel 
2. 查看 192.168.1.9 / 192.168.1.10 的開機時間 
-H 要操作的主機 
-i 要執行的命令 
# pssh -H “192.168.1.9 192.168.1.10” -i “uptime” 
[1] 11:19:10 [FAILURE] 192.168.1.10 Exited with error code 255 
Stderr: pssh error: SSH requested a password. Please create SSH keys or use 
the -A option to provide a password. 
Permission denied (publickey,password). 
[2] 11:19:20 [FAILURE] 192.168.1.9 Exited with error code 255 
Stderr: pssh error: SSH requested a password. Please create SSH keys or use 
the -A option to provide a password. 
Permission denied (publickey,password). 
上面提示需要輸入密碼,可以使用 -A 參數[@more@]3. 加上 -A 參數 
# pssh -A -H “192.168.1.9 192.168.1.10” -i “uptime” 
Warning: do not enter your password if anyone else has superuser 
privileges or access to your account. 
Password: 
[1] 11:24:20 [SUCCESS] 192.168.1.9 
 11:24:20 up 13 days, 16:43, 2 users, load average: 0.57, 0.48, 0.47 
[2] 11:24:20 [SUCCESS] 192.168.1.10 
 11:24:20 up 4 days, 20:20, 0 users, load average: 0.02, 0.06, 0.07 
4. 如果二台密碼不相同,就要使用 ssh key 的方式來處理 
# pssh -A -H “192.168.1.99 192.168.1.8” -i “uptime” 
Warning: do not enter your password if anyone else has superuser 
privileges or access to your account. 
Password: 
[1] 11:26:18 [SUCCESS] 192.168.1.99 
 11:26:18 up 13 days, 16:45, 2 users, load average: 0.29, 0.39, 0.44 
[2] 11:26:20 [FAILURE] 192.168.1.8 Exited with error code 255 
Stderr: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). 
5. 將要連線的 Server 清單放在檔案之中 
# cat pssh_hosts.txt 
root@192.168.1.9 
root@192.168.1.10 
# pssh -A -h pssh_hosts.txt -i “uptime” 
Warning: do not enter your password if anyone else has superuser 
privileges or access to your account. 
Password: 
[1] 11:24:20 [SUCCESS] 192.168.1.9 
 11:24:20 up 13 days, 16:43, 2 users, load average: 0.57, 0.48, 0.47 
[2] 11:24:20 [SUCCESS] 192.168.1.10 
 11:24:20 up 4 days, 20:20, 0 users, load average: 0.02, 0.06, 0.07 
6. 更多的參數 
# pssh –help 
Usage: pssh [OPTIONS] command […] 
Options: 
 –version show program’s version number and exit 
 –help show this help message and exit 
 -h HOST_FILE, –hosts=HOST_FILE 
 hosts file (each line “[user@]host[:port]”) 
 -H HOST_STRING, –host=HOST_STRING 
 additional host entries (“[user@]host[:port]”) 
 -l USER, –user=USER username (OPTIONAL) 
 -p PAR, –par=PAR max number of parallel threads (OPTIONAL) 
 -o OUTDIR, –outdir=OUTDIR 
 output directory for stdout files (OPTIONAL) 
 -e ERRDIR, –errdir=ERRDIR 
 output directory for stderr files (OPTIONAL) 
 -t TIMEOUT, –timeout=TIMEOUT 
 timeout (secs) (0 = no timeout) per host (OPTIONAL) 
 -O OPTION, –option=OPTION 
 SSH option (OPTIONAL) 
 -v, –verbose turn on warning and diagnostic messages (OPTIONAL) 
 -A, –askpass Ask for a password (OPTIONAL) 
 -x ARGS, –extra-args=ARGS 
 Extra command-line arguments, with processing for 
 spaces, quotes, and backslashes 
 -X ARG, –extra-arg=ARG 
 Extra command-line argument 
 -i, –inline inline aggregated output and error for each server 
 –inline-stdout inline standard output for each server 
 -I, –send-input read from standard input and send as input to ssh 
 -P, –print print output as we get it 
Example: pssh -h hosts.txt -l irb2 -o /tmp/foo uptime
