warren6

 

CentOS免密登录

CentOS免密登录

#!/bin/sh

pass=root123
yum install expect -y
echo "y"|ssh-keygen -t rsa -P "" -f /root/.ssh/id_rsa
iplist="k8s-master1 k8s-master2 k8s-master3"


for i in ${iplist};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 "${pass}"\r;exp_continue}
    timeout { }
}"
done
exit

posted on 2022-10-10 13:46  Warren6  阅读(23)  评论(0编辑  收藏  举报

导航