Skip to content

Instantly share code, notes, and snippets.

@nmattia
Last active June 26, 2016 13:33
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 nmattia/1c017c65172c3ec6e57881860cedbf16 to your computer and use it in GitHub Desktop.
Save nmattia/1c017c65172c3ec6e57881860cedbf16 to your computer and use it in GitHub Desktop.
Use github to get ssh authorized keys
#!/bin/sh
#
# Fetches SSH keys from a github user
# Big kudos to @zimbatm for inspiration: https://gist.github.com/zimbatm/3166cc0bbb46551fe67e
#
# Usage:
# curl -L https://goo.gl/Jj330b | user=<github username> sh
#
if [ -z "$user" ]; then
user=nmattia
fi
mkdir -m 0700 -p "$HOME/.ssh"
curl "https://api.github.com/users/$user/keys" | grep 'key":'| sed -e 's/.*"\(ssh-.*\)".*/\1/' > "$HOME/.ssh/authorized_keys"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment