Skip to content

Instantly share code, notes, and snippets.

@chorrell
Last active December 17, 2015 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chorrell/5686383 to your computer and use it in GitHub Desktop.
Save chorrell/5686383 to your computer and use it in GitHub Desktop.
Backup ssh keys from your Joyent account to /root/.ssh/authorized_keys. Don't forget to change ACCOUNT, DC, and AUTHORIZED_KEYS. Schedule this via cron to always ensure you have a recent backup NOTE: this assumes you have smartdc (the latest 7.0 version) and jsontool installed (via npm): 'npm install smartdc -g; npm install jsontool -g`
#!/bin/bash
PKGSRCPATH=/opt/local
ACCOUNT=YOUR-USER-NAME
FINGERPRINT=`ssh-keygen -l -f ~/.ssh/id_rsa.pub | awk '{print $2}' | tr -d '\n'`
URL=https://DC.api.joyentcloud.com
AUTHORIZED_KEYS=/root/.ssh/authorized_keys
${PKGSRCPATH}/bin/sdc-listkeys --account ${ACCOUNT} --keyId ${FINGERPRINT} --url ${URL} | ${PKGSRCPATH}/bin/json -a key > ${AUTHORIZED_KEYS}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment