Loading

免密脚本

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
posted @ 2023-02-22 10:46  小维江湖  阅读(22)  评论(0编辑  收藏  举报