Skip to content

Instantly share code, notes, and snippets.

@wouterd
Created January 6, 2021 10:56
Show Gist options
  • Save wouterd/965bee44de6df42ce2864cbdbf74cd78 to your computer and use it in GitHub Desktop.
Save wouterd/965bee44de6df42ce2864cbdbf74cd78 to your computer and use it in GitHub Desktop.
Password-store scripts
#!/bin/bash -eu
TMP_DIR="$(mktemp -d)"
gpg --export-ownertrust > "${TMP_DIR}/gpg-ownertrust.txt"
gpg --export-secret-key -a "MY EMAIL HERE" > "${TMP_DIR}/private-key.txt" || true
cp -r ~/.ssh "${TMP_DIR}/"
cd "${TMP_DIR}"
tar cf keys.tar * .ssh
gpg -c "${TMP_DIR}/keys.tar"
rm "${TMP_DIR}/keys.tar"
mv "${TMP_DIR}/keys.tar.gpg" ~/"Google Drive/keys.tar.gpg"
#!/bin/bash -eu
cd
[ -f "Google Drive/keys.tar.gpg" ] || exit 0
[ -f .keys.tar.gpg.sha ] && sha512sum --status -c .keys.tar.gpg.sha && exit 0
echo Updated keys available, decrypting...
sha=$(sha512sum "Google Drive/keys.tar.gpg")
gpg -o - "Google Drive/keys.tar.gpg" | tar x
gpg --import-ownertrust gpg-ownertrust.txt
echo "$sha" > .keys.tar.gpg.sha
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment