安装 expect
[root@localhost ~]# yum install expect [root@localhost ~]# cat 1.sh #!/bin/bash SERVERS="192.168.1.180 192.168.1.170 192.168.1.178 192.168.1.186 192.168.1.190 192.168.1.174 192.168.1.175 192.168.1.183 192.168.1.173 192.168.1.181 192.168.1.184 192.168.1.179 192.168.1.177 192.168.1.169 192.168.1.189 192.168.1.185 192.168.1.182 192.168.1.167 192.168.1.163 192.168.1.164 192.168.1.162 192.168.1.165 192.168.1.167 192.168.1.168 192.168.1.193 192.168.1.195 192.168.1.191 192.168.1.194 192.168.1.62 192.168.1.68 192.168.1.198 192.168.1.57 192.168.1.143 192.168.1.71 192.168.1.13 192.168.1.80 192.168.1.142 192.168.1.64 192.168.1.66 192.168.1.11 192.168.1.63 192.168.1.147 192.168.1.14 192.168.1.9 192.168.1.87 192.168.1.67 192.168.1.61 192.168.1.12 192.168.1.78 192.168.1.144 192.168.1.253 192.168.1.138 192.168.1.52 192.168.1.75 192.168.1.212 192.168.1.65 192.168.1.93 192.168.1.58 192.168.1.209 192.168.1.72 192.168.1.41 192.168.1.54 192.168.1.152 192.168.1.51 192.168.1.214 192.168.1.60 192.168.1.139 192.168.1.55 192.168.1.210 192.168.1.153 192.168.1.137 192.168.1.211 192.168.1.49 192.168.1.59 192.168.1.53 " PASSWORD=GR2df018629. auto_ssh_copy_id() { expect -c "set timeout -1; spawn ssh-copy-id $1; expect { *(yes/no)* {send -- yes\r;exp_continue;} *assword:* {send -- $2\r;exp_continue;} eof {exit 0;} }"; } ssh_copy_id_to_all() { for SERVER in $SERVERS do auto_ssh_copy_id $SERVER $PASSWORD done } ssh_copy_id_to_all
继续阅读
- 我的QQ
- QQ扫一扫
-
- 我的头条
- 头条扫一扫
-
评论