yum install sshpass -y
if [ ! -f /root/.ssh/id_rsa ]; then
ssh-keygen -t rsa -b 2048 -N '' -f /root/.ssh/id_rsa > /dev/null
fi
export NODE_NAMES=(master1 master2 master3 node1 node2 node3)
export pwd="rootpassword"
for node in ${NODE_NAMES[@]}
do
echo ">>> ${node}"
sshpass -p ${pwd} ssh-copy-id -o StrictHostKeyChecking=no root@${node} 2>/dev/null
done
标签:脚本,node,免密,rsa,export,ssh,root,id
From: https://www.cnblogs.com/xwjh/p/17143566.html