Skip to content

Instantly share code, notes, and snippets.

@adrienjoly
Created December 12, 2021 09:51
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 adrienjoly/ff3a9bea111c5487882a7ba327c5a03b to your computer and use it in GitHub Desktop.
Save adrienjoly/ff3a9bea111c5487882a7ba327c5a03b to your computer and use it in GitHub Desktop.
Commands to archive, encrypt and decrypt secret files using gpg's symmetric encryption.
TAR_FILE="secret-archive.tgz"
DEST_FILE="crypted-secret-archive.tgz.gpg"
# Archive
tar cvzf "${TAR_FILE}" ${SECRET_FILES_PATH}/*
# Encrypt
echo "${GPG_PASSPHRASE}" | gpg --batch --yes --passphrase-fd 0 -o "${DEST_FILE}" --symmetric "${TAR_FILE}"
# Decrypt
echo "${GPG_PASSPHRASE}" | gpg --batch --yes --passphrase-fd 0 --decrypt "${DEST_FILE}" > "${DECRYPTED_FILE}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment