Created
March 17, 2017 02:51
-
-
Save don-smith/4ed3cd80fd67fe342fa2f31ba3906ed1 to your computer and use it in GitHub Desktop.
Creates an SSH key to use on GitHub
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/sh | |
# This script creates an SSH key for use on GitHub | |
# Step 1: Copy and paste this github() function into the ~/.zshrc file | |
github() { | |
eval "$(ssh-agent -s)" | |
ssh-add ~/.ssh/$1 | |
email=`cat ~/.ssh/$1.email` | |
git config --global user.name $1 | |
git config --global user.email $email | |
} | |
# Step 2: Source .zshrc by running this in the terminal: | |
# source ~/.zshrc | |
# Step 3: Run this script passing the the GitHub username and | |
# email address associated with the GitHub account (see usage) | |
# Step 4: Apply credentials locally by running this in the terminal: | |
# github github-username | |
usage() { | |
echo "" | |
echo "This script creates an SSH key for use on GitHub." | |
echo "" | |
echo "./github.sh github-username github-email" | |
echo "" | |
} | |
createkey() { | |
echo $2 >> ~/.ssh/$1.email | |
ssh-keygen -t rsa -b 4096 -f ~/.ssh/$1 -C $2 | |
cp ~/.ssh/$1 . | |
cp ~/.ssh/$1.pub . | |
cp ~/.ssh/$1.email . | |
pbcopy < ./$1.pub | |
echo "Your public key has been copied to your clipboard." | |
echo "Go to https://github.com/settings/keys and create a new SSH key." | |
echo "Name the key 'EDA' and use the contents of your clipboard." | |
} | |
if [ "$#" -lt 2 ]; then | |
usage | |
else | |
createkey $1 $2 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment