Skip to content

Instantly share code, notes, and snippets.

@justinian
Created December 12, 2017 03:52
Show Gist options
  • Save justinian/d94a825ace90a60fddf8d71519ab5550 to your computer and use it in GitHub Desktop.
Save justinian/d94a825ace90a60fddf8d71519ab5550 to your computer and use it in GitHub Desktop.
Script to update SSH keys from Github
#!/usr/bin/env bash
PROFILE=${1:-justinian}
USER=${2:-justin}
OUTFILE="/home/${USER}/.ssh/authorized_keys"
TEMPFILE=$(mktemp)
if curl -sL "https://github.com/${PROFILE}.keys" > "${TEMPFILE}"; then
if grep -q "ssh-rsa" "${TEMPFILE}"; then
cat "${TEMPFILE}" > "${OUTFILE}"
fi
fi
rm "${TEMPFILE}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment