SSH 免秘钥登录

yum -y install expect
ssh-keygen -t rsa -P "" -f /root/.ssh/id_rsa
for i in 192.168.1.11 192.168.1.12 192.168.1.13 192.168.1.14  k8s-master1 k8s-master2 k8s-master3 k8s-node1;do
expect -c "
spawn ssh-copy-id -i /root/.ssh/id_rsa.pub root@$i
    expect {
        \"*yes/no*\" {send \"yes\r\"; exp_continue}
        \"*password*\" {send \"Flyaway.123\r\"; exp_continue}
        \"*Password*\" {send \"Flyaway.123\r\";}
    } "
done

 

posted on 2020-10-30 11:18  蜂蜜log  阅读(85)  评论(0编辑  收藏  举报

导航