#!/usr/bin/env bash# Check if user is not root[["$(whoami)"=="root"]]&&echo"Do not run with root user!"&&exit1USERNAME=$(whoami)SERVERS=("10.10.10.10""10.10.10.11""10.10.10.12""10.10.10.13")PUB_FOLDER="id-rsa-pub-files"read-r-d''COMMAND<< EOM/usr/bin/ssh-keygen -t rsachmod 600 ~/.ssh/id_rsaEOMrm-rf"${PUB_FOLDER}"mkdir"${PUB_FOLDER}"forserverin"${SERVERS[@]}";doecho-e"\n************ ${server} ************\n"# copy ssh-keyssh-copy-id-f"${USERNAME}@${server}"# Run 'generate key' and 'change mod' command on serverssh"${USERNAME}@${server}""${COMMAND}"# Copy 'id_rsa.pub' file to localscp"${USERNAME}@${server}:/home/${USERNAME}/.ssh/id_rsa.pub""${PUB_FOLDER}/${server}.id_rsa.pub"doneecho"Pub files downloaded to ${PUB_FOLDER}"