标签:tps finish 博文 作者 null hosts send centos host
首先执行产生密钥操作
#################批量推公钥##################
#!/bin/bash
#abel
>ip.txt
>/root/.ssh/known_hosts
if [ ! -f ~/.ssh/id_rsa.pub ];then
ssh-keygen -P "" -f ~/.ssh/id_rsa
exit
fi
yum -y install expect
for i in {2..254}
do
{
ip=192.168.122.$i
ping -c1 -W1 $ip &>/dev/null
if [ $? -eq 0 ];then
echo $ip >> ip.txt
/usr/bin/expect <<-EOF
set timeout 10
spawn ssh-copy-id -i $ip
expect {
"*yes/no" { send "yes\r"; exp_continue}
"*password:" { send "centos\r" }
}
expect "#"
send "exit\r"
expect eof
EOF
fi
}&
done
wait
echo "finish...."
---------------------
作者:abel_dwh
来源:CSDN
原文:https://blog.csdn.net/abel_dwh/article/details/78468007
版权声明:本文为博主原创文章,转载请附上博文链接!
标签:tps finish 博文 作者 null hosts send centos host
原文地址:https://www.cnblogs.com/sunshinea121/p/10650397.html