#!/usr/bin/env bash # # pack.sh Bash script to wrap tar archiving and gpg/pgp encrypt directories or single files. # www.braggtown.com 4096 bit encryption to go! # # Usage: pack.sh or pack.sh # Creates an encrypted archive at location of target file or directory # # Useful to transport sensitive data on untrusted media such as external drives, USB drives, # and for making data accessible on the web but maintaining security of the data. # It relies on GPG being configured correctly and will encrypt to the public key of the default user. # It prefers to use wipe to delete unencrypted tar, but will use rm if necessary. See http://abaababa.ouvaton.org/wipe/ # To unencrypt and untar the data: "gpg --decrypt --output .tar .tar.pgp && tar xvf .tar" echo "Archiving $1" tar -cvf $1.tar $1 > /dev/null #comment out the " > /dev/null" redirect to see tar's list of files added echo "Encrypting $1" gpg --default-recipient-self -e $1.tar mv $1.tar.gpg $1.tar.pgp # prefer to use .pgp extension since Gnome recoginizes it and uses appropriate icon if [ -f /usr/bin/wipe ]; then wipe -sf $1.tar #wipe -sf $1 # uncomment this command to wipe the original file/directory. Use with caution. else rm -rf $1.tar # uncomment this command to rm the original file/directory. Use with caution. #rm -rf $1 fi exit 0