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?
Asked
Active
Viewed 1.7k times
2 Answers
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.