Skip to content

Instantly share code, notes, and snippets.

@ollyg
Last active June 25, 2020 10:46
Show Gist options
  • Save ollyg/2c5f136bfcf4a107665e616f8ff7faee to your computer and use it in GitHub Desktop.
Save ollyg/2c5f136bfcf4a107665e616f8ff7faee to your computer and use it in GitHub Desktop.
# curl -f >> onto authorized_keys
# grep a_k for certs
# if more than two lines
# sed out the first N of them
curl -sf https://my-cert.pub >> ~/.ssh/authorized_keys &&
sed -i '' '1!G;h;$!d' ~/.ssh/authorized_keys &&
awk '!/^cert-authority / || ++n < 3' ~/.ssh/authorized_keys > ~/.ssh/authorized_keys.tmp &&
sed '1!G;h;$!d' ~/.ssh/authorized_keys.tmp > ~/.ssh/authorized_keys &&
rm ~/.ssh/authorized_keys.tmp &&
chmod 600 ~/.ssh/authorized_keys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment