Skip to content

Instantly share code, notes, and snippets.

@satoruk
Created March 2, 2017 13:08
Show Gist options
  • Save satoruk/1866c502b4dff531bd559c3a0ea049df to your computer and use it in GitHub Desktop.
Save satoruk/1866c502b4dff531bd559c3a0ea049df to your computer and use it in GitHub Desktop.
#!/bin/bash -e
TEMP_FILE=/tmp/authorized_keys
KEYS_FILE=~/.ssh/authorized_keys
GITHUB_USER=$1
test -n $GITHUB_USER
echo "Sync SSH authorized keys from Github user ${GITHUB_USER}"
mkdir --mode=700 -p ~/.ssh
curl -f -o $TEMP_FILE https://github.com/${GITHUB_USER}.keys
touch $KEYS_FILE
chmod 600 $KEYS_FILE
cat $TEMP_FILE $KEYS_FILE | sort | uniq > $KEYS_FILE
rm $TEMP_FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment