title: CentOS免密登录
categories: CentOS
tags: 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
标签:免密,CentOS,登录,expect,k8s,id,ssh
From: https://www.cnblogs.com/warren6/p/16775451.html