Created
August 15, 2016 01:29
-
-
Save arobb/bb10f62369266882b1b07292566f6a03 to your computer and use it in GitHub Desktop.
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 | |
# Decrypt GPG files in current directory | |
# Files created with gpg --armor --output <out enc file> --symmetric --cipher-algo AES256 <in clear file> | |
read -s -p "Enter Password: " pw | |
echo -ne "\033[0K\r" | |
for infile in *.gpg; | |
do | |
outfile=${infile%.gpg} | |
# Remove an existing file | |
rm -f "$outfile" >/dev/null 2>&1 | |
# Decrypt the file | |
echo "$pw" | gpg --batch --passphrase-fd 0 --output "$outfile" --decrypt "$infile" >/dev/null 2>&1 | |
result=$? | |
if [ "$result" -eq "0" ]; | |
then | |
# Set the permissions | |
chmod 0400 $outfile | |
echo "$outfile ready" | |
else | |
echo "Could not extract $infile" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment