Last active
June 26, 2016 13:33
-
-
Save nmattia/1c017c65172c3ec6e57881860cedbf16 to your computer and use it in GitHub Desktop.
Use github to get ssh authorized keys
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
#!/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