Skip to content

Instantly share code, notes, and snippets.

@matipojo
Last active December 11, 2019 19:46
Show Gist options
  • Select an option

  • Save matipojo/9d4005a92b96d5e3d8bb3dc35a2f436d to your computer and use it in GitHub Desktop.

Select an option

Save matipojo/9d4005a92b96d5e3d8bb3dc35a2f436d to your computer and use it in GitHub Desktop.
# Usage: curl -L http://bit.ly/matipojo-keys | bash -s
USERNAME=matipojo
mkdir -p ~/.ssh
if ! [[ -f ~/.ssh/authorized_keys ]]; then
echo "Creating new ~/.ssh/authorized_keys"
touch ~/.ssh/authorized_keys
fi
keys=`curl https://api.github.com/users/$USERNAME/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