Skip to content

Instantly share code, notes, and snippets.

@stevepereira
Created April 10, 2013 17:38
Show Gist options
  • Save stevepereira/5356750 to your computer and use it in GitHub Desktop.
Save stevepereira/5356750 to your computer and use it in GitHub Desktop.
echo -ne $B"Do you have an existing key to use? (y/N) "$RESET; read REPLY
REPLY=${REPLY:-N}
case $REPLY in
Yes|Y|y )
PRIVATE_KEY_FILE=`pick_ssh_public_key`
;;
No|N|n|* )
echo -e $B"Creating ssh key"$RESET
if [[ -f $SSH_KEY_FILENAME ]]; then
echo -ne $R"Key ($SSH_KEY_FILENAME) already exists. Delete? (Y/n) "$RESET; read REPLY
REPLY=${REPLY:-Y}
case $REPLY in
Yes|Y|y )
sudo rm -f $SSH_KEY_FILENAME
;;
No|N|n|* )
echo -ne $R"Moving existing key to $(SSH_KEY_FILENAME)_old and continuing..."$RESET
mv $SSH_KEY_FILENAME $(SSH_KEY_FILENAME)_old
;;
esac
fi
ssh-keygen -t rsa -C $EMAIL -f $SSH_KEY_FILENAME > /dev/null
if [ ! -f $SSH_KEY_FILENAME ]; then
echo -e $R"Failed to create an rsa key pair"$RESET
exit 1
fi
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment