机器互通
[root@k8s-deploy:~]# ssh-keygen -t rsa-sha2-512 -b 4096
[root@k8s-deploy:~]# apt install sshpass #安装sshpass命令⽤于同步公钥到各k8s服务器
[root@k8s-deploy:~]# vim key-scp.sh
########(51、52、532为k8smaster)(56、57、58为k8s集群中的etcd) (60、61、62为node节点)
########!/bin/bash
########⽬标主机列表
IP="
10.0.0.51
10.0.0.52
10.0.0.53
10.0.0.56
10.0.0.57
10.0.0.58
10.0.0.61
10.0.0.62
10.0.0.63
"
REMOTE_PORT="22"
REMOTE_USER="root"
REMOTE_PASS="123456"
for REMOTE_HOST in ${IP};do
REMOTE_CMD="echo ${REMOTE_HOST} is successfully!"
#添加⽬标远程主机的公钥
ssh-keyscan -p "${REMOTE_PORT}" "${REMOTE_HOST}" >> ~/.ssh/known_hosts
#通过sshpass配置免秘钥登录、并创建python3软连接
sshpass -p "${REMOTE_PASS}" ssh-copy-id "${REMOTE_USER}@${REMOTE_HOST}"
ssh ${REMOTE_HOST} ln -sv /usr/bin/python3 /usr/bin/python
echo ${REMOTE_HOST} 免秘钥配置完成!
done