Skip to content

Instantly share code, notes, and snippets.

@namick
Forked from rtlong/get-keys-for-github-user.sh
Created October 17, 2013 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save namick/7029191 to your computer and use it in GitHub Desktop.
Save namick/7029191 to your computer and use it in GitHub Desktop.
IFS="$(printf '\n\t')"
if ! [[ -f ~/.ssh/authorized_keys ]]; then
echo "Creating new ~/.ssh/authorized_keys"
touch ~/.ssh/authorized_keys
fi
user=$1
keys=`curl https://api.github.com/users/$user/keys | grep -o -E "ssh-\w+\s+[^\"]+"`
for key in $keys; do
echo $key
grep -q "$key" ~/.ssh/authorized_keys || echo "$key" >> ~/.ssh/authorized_keys
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment