免密脚本
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