Skip to content

Instantly share code, notes, and snippets.

@arobb
Created August 15, 2016 01:29
Show Gist options
  • Save arobb/bb10f62369266882b1b07292566f6a03 to your computer and use it in GitHub Desktop.
Save arobb/bb10f62369266882b1b07292566f6a03 to your computer and use it in GitHub Desktop.
#!/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