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