#!/bin/bash
yum -y install ansible #安装ansible
yum -y install expect
for i in 10.0.0.{41..49} #定义主机范围
do
password="123456" #密码
/usr/bin/expect -c"
spawn ssh-copy-id -i /root/.ssh/id_rsa.pub root@$i
expect {
\"*(yes/no)\" { send \"yes\r\";exp_continue }
\"*password\" { send \"$password\r\"; exp_continue }
}
expect eof"
done
sshpass批量拷贝公钥(shell)
最新推荐文章于 2021-10-15 17:41:33 发布