Decrypting Multiple Files with GnuPG

22 Apr

>Here’s a simple UNIX/Linux script that asks for a password and then decrypts a batch of files using that password, using GnuPG:


echo -n "Enter password: "
stty -echo
read password
stty echo

for encrypted in *.gpg; do
decrypted=`echo ${encrypted} | sed s/.gpg\$//`
echo -n ${decrypted}
echo "${password}" | gpg --passphrase-fd 0 -o "${decrypted}" -d "${encrypted}" > /dev/null 2> /dev/null
if [ "$?" = "0" ]; then
chmod 600 "${decrypted}"
echo " [ DONE ]"
echo " [ FAILED ]"
1 Comment

Posted by on 22 April 2009 in decrypt, decryption, gnupg, password


One response to “Decrypting Multiple Files with GnuPG

  1. test blog

    8 October 2010 at 09:03

    >or you can use…gpg –decrypt –multifile *.gpgor even bettergpg –decrypt-files *.gpgwhich is more secure than passing your passphrase to stdout


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: