Skip to content

Instantly share code, notes, and snippets.

@cbronazc
Last active August 29, 2015 14:04
Show Gist options
  • Save cbronazc/20422f81f32f7a1f7c7c to your computer and use it in GitHub Desktop.
Save cbronazc/20422f81f32f7a1f7c7c to your computer and use it in GitHub Desktop.
Encrypt/Decrypt a folder with gpg
#!/bin/sh
OPTIND=1
infile=
while getopts e:d: opt; do
case $opt in
e)
infile=$OPTARG
tar cvf - $infile | gpg --cipher-algo AES256 --symmetric > ./$infile.tbz
;;
d)
infile=$OPTARG
gpg -o- $infile.tbz | tar zxvf -
;;
esac
done
# Using gpg this way does not use a public/private key, just a password.
# This allows us to transfer files around computers and not worry about gpg keys.
# Install gpg
# Save in /usr/local/bin/ and `chmod +x` it.
# To Encrypt:
#
# foldEnc.sh -e folder_name (no /)
# (Asks for pw)
# => folder_name.tbz
# To Decrypt:
#
# foldEnc.sh -d folder_name (no extension)
# (Asks for pw)
# => folder_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment