pssh 使用記錄

1、pssh 安裝

yum -y install epel-release
yum -y install pssh

安裝完畢後有一下命令:
pssh       ssh執行命令
pscp.pssh  copy到遠程
pslurp     pull從遠程
pnuke      kill遠程進程
prsync     同步

2、ssh 免密配置

 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、我常用的方式

3.1、遠程yum 軟件

 pssh -p 4  -h ip.txt  -i   "yum -y install screen"

3.2、遠程kill 進程

pssh -p 2  -h ip.txt  -i   "sudo pkill -9 top"

3.3、拷貝文件到遠程服務器

 pscp.pssh -h ip.txt ip.txt /tmp/ip.tmp

3.4、拉遠程文件

[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 ~]#

附錄:

[root@mgr ~]# cat ip.txt 
192.168.56.13
192.168.56.14
192.168.56.15
192.168.56.16
[root@mgr ~]#


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章