Created
November 10, 2010 11:31
-
-
Save IanVaughan/670728 to your computer and use it in GitHub Desktop.
setup_ssh.sh - copies SSH public keys between hosts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
HOST=0 | |
if [ "$SYSTEM" == "type1" ]; then | |
HOST=192.168.0.2 | |
elif [ "$SYSTEM" == "type2" ]; then | |
HOST=192.168.0.1 | |
else | |
echo "Error 1" | |
exit | |
fi | |
LOG_FILE=/root/setup_ssh.log | |
SSH_PATH=/root/.ssh | |
SSH_KEY=${SSH_PATH}/id_rsa | |
SSH_PUB=${SSH_PATH}/id_rsa.pub | |
if [ ! -f ${SSH_KEY} ]; then | |
ssh-keygen -f ${SSH_KEY} -N "" >> ${LOG_FILE} 2>&1 | |
fi | |
echo "If asked, enter the Scorpion2 password, if not asked, keys already exchanged..." | |
cat ${SSH_PUB} | ssh ${HOST} -o StrictHostKeyChecking=no "mkdir -p ${SSH_PATH} && cat >> ${SSH_PATH}/authorized_keys" | |
echo "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment