Created
November 11, 2014 18:01
-
-
Save cmbaughman/39be54b6ea874709c931 to your computer and use it in GitHub Desktop.
Generate New Github.com key
This file contains hidden or 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 | |
shopt -s -o nounset | |
declare -rx SCRIPT=${0##*/} | |
# NOTE: Edit these variables to be whatever you want them to be for your Github key! | |
declare -rx EMAIL="PUT_EMAIL_HERE" | |
declare -rx KEYID='PUT_KEYNAME_HERE' | |
if test -z "$BASH"; then | |
printf "$SCRIPT:$LINENO: Please use the bash shell to run this script.\n" >&2; | |
exit 192 | |
fi | |
if [ -f $KEYID ]; then | |
KEYID=${KEYID}`date +%s` | |
fi | |
ssh-keygen -t rsa -N "" -f ~/.ssh/$KEYID -C "${EMAIL}" | |
# Add key to ssh-agent if you have it | |
eval "$(ssh-agent -s)" | |
ssh-add ~/.ssh/${KEYID} | |
printf "Generated a new key to use in Github!\n"; | |
printf "Paste this in to the Github.com interface:\n\n"; | |
cat ~/.ssh/${KEYID}.pub | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment