#下面的密码你改改就行了 我的机器也用的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
"; exp_continue}
"*password*" {send "123456
"; exp_continue}
"*Password*" {send "123456
";}
} "
done