16

I have a directory with multiple .gpg files, all encrypted with the same passphrase. How can I decrypt them all without entering the passphrase over and over?

Chris Shain
  • 481
  • 1
  • 3
  • 11

2 Answers2

18

It seems like this does the trick:

gpg --decrypt-files *.gpg
Chris Shain
  • 481
  • 1
  • 3
  • 11
1

In case you one day need the lines to script a solution

#!/usr/bin/env bash
_dir="/some/directory"
_paraphrase=( "$@" )
Decrypt(){
    _pass=( "$@" )
    for _file in $(ls "${_dir}"); do
        case "${_file}" in
            *.gpg)
                echo "${_pass[*]}" | gpg --always-trust --passphrase-fd 0 --decrypt ${_file} --output ${_file%.gpg*}
            ;;
        esac
    done
    unset _pass
}
Decrypt "${_paraphrase[*]}"
unset _paraphrase

Some similar code works great in my personal GnuPG scripts that have to decrypt without human interaction. However the accepted answer of gpg --decrypt-files *.gpg is far more secure because GnuPG is the only application handling your password.

Whois_me
  • 3
  • 4
S0AndS0
  • 171
  • 1
  • 1
  • 6