k8s的一键分发秘钥 需要yum install expect

#下面的密码你改改就行了 我的机器也用的123456
ssh-keygen -t rsa -P "" -f /root/.ssh/id_rsa
for i in k8s-1 k8s-2 k8s-3;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 \"123456\r\"; exp_continue}
                \"*Password*\" {send \"123456\r\";}
        } "
done 

posted on 2019-12-10 09:52  石圪节胡德禄  阅读(237)  评论(0)    收藏  举报

导航