Created
May 2, 2018 23:42
-
-
Save johnnyopao/33c6500bda474a7afb33207489d8e8e5 to your computer and use it in GitHub Desktop.
GPG Encrypt all files in directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This uses gpg to encrypt every file in a directory as separate | |
# encrypted files | |
# Usage | |
# ./encrypt-all.sh ./dir-of-files-to-encrypt "PASSPHRASE" | |
FILES="$1" | |
PASSPHRASE="$2" | |
pushd $FILES | |
for file_name in ./*; do | |
enc_name="$file_name.enc" | |
echo "Encrypting $file_name" | |
gpg \ | |
--passphrase "$PASSPHRASE" \ | |
--batch \ | |
--output "$file_name.enc" \ | |
--symmetric \ | |
--cipher-algo AES256 \ | |
"$file_name" | |
echo "Done! Output: $enc_name" | |
done | |
popd |
./encrypt-all.sh: command not found
@robertkeogh it might be that you don't have gpg installed. If you don't have it, here's an article that has installation steps
http://blog.ghostinthemachines.com/2015/03/01/how-to-use-gpg-command-line/
works perfect!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I get the following error when I try to run the above script even with sudo