一、pssh 安裝shell
yum -y install epel-release yum -y install pssh 安裝完畢後有一下命令: pssh ssh執行命令 pscp.pssh copy到遠程 pslurp pull從遠程 pnuke kill遠程進程 prsync 同步
二、ssh 免密配置bash
yum -y install expect ssh-keygen -t rsa -f ~/.ssh/id_rsa -N "" -q cat << EEE >>/tmp/sshkey.sh for ip in {192.168.56.13,192.168.56.14,192.168.56.15,192.168.56.16} do expect << EOF spawn ssh-copy-id -i /root/.ssh/id_rsa.pub root@$ip expect { "yes/no" { send "yes\n";exp_continue} "password" { send "123456\n"} } expect eof EOF done EEE /*那是一個描述符,告訴 shell ,管道符操做遇到這個東西就停下來。 EOF 只是一個通用的稱呼,其實換成別的也是能夠的。這看你文件裏面的具體要求。*/
三、我經常使用的方式服務器
3.一、遠程yum 軟件ssh
pssh -p 4 -h ip.txt -i "yum -y install screen"
3.二、遠程kill 進程
ide
pssh -p 2 -h ip.txt -i "sudo pkill -9 top"
3.三、拷貝文件到遠程服務器spa
pscp.pssh -h ip.txt ip.txt /tmp/ip.tmp
3.四、拉遠程文件
進程
[root@mgr ~]# pslurp -h ip.txt /tmp/ip.tmp /rip.txt [1] 11:53:38 [SUCCESS] 192.168.56.15 [2] 11:53:38 [SUCCESS] 192.168.56.14 [3] 11:53:38 [SUCCESS] 192.168.56.13 [4] 11:53:38 [SUCCESS] 192.168.56.16 [root@mgr ~]# ls 192.168.56.1*/ 192.168.56.13/: rip.txt 192.168.56.14/: rip.txt 192.168.56.15/: rip.txt 192.168.56.16/: rip.txt [root@mgr ~]#
附錄:ip
[root@mgr ~]# cat ip.txt 192.168.56.13 192.168.56.14 192.168.56.15 192.168.56.16 [root@mgr ~]#