Created
January 24, 2017 21:50
-
-
Save lwoodson/3ad5532ff50f7c5ddb8d2bc0a39c8875 to your computer and use it in GitHub Desktop.
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
set -o errexit | |
set -o nounset | |
# This is a convenience script to set up your user on a host with your public | |
# SSH keys obtained from github. No warranty. Use at your own risk. | |
GITHUB_USER=${GITHUB_USER:=$USER} | |
echo Setting up ${USER} with for ssh auth using keys of ${GITHUB_USER} in github... | |
echo | |
echo "Setting up ~/.ssh directory..."y | |
if [ -d ~/.ssh ]; then | |
echo "~/.ssh directory exists; What were you thinking?!" | |
exit -1 | |
else | |
mkdir ~/.ssh | |
chmod 700 ~/.ssh | |
fi | |
echo Done. | |
echo "Setting up authorized_keys file..." | |
if [ -f ~/.ssh ]; then | |
echo "~/.ssh/authorized_keys file exists; What were you thinking?!" | |
exit -1 | |
else | |
curl --silent https://api.github.com/users/${USER}/keys \ | |
| grep key \ | |
| cut -c 13-736 \ | |
> ~/.ssh/authorized_keys | |
chmod 600 ~/.ssh/authorized_keys | |
fi | |
echo Done. | |
echo Finished setting up host. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment