I will be receiving PGP encrypted files from a customer through sFTP - I already have a process to automate pulling of files. Once I receive the encrypted file, I'd like to automate decryption.
I created a key pair with GoAnywhere OpenPGP Studio (public key will go to customer). I want to use the private key along with the secret passphrase in a batch file script that will run as a scheduled task in Windows Task Scheduler. This is my script:
gpg --keyring "C:\UserFolder\.openpgpstudio\keys\pubring.pkr" --secret-keyring "C:\UserFolder\.openpgpstudio\keys\secring.skr" --batch --yes --passphrase-fd "secretPassPhrase" -o "D:\FilePath\testPGP.txt" -d "D:\FilePath\testPGP.txt.pgp"
exit
When I try to run my script, there are still some manual steps needed to decrypt files - there are a couple issues I faced:
--passphrase-fd
option, there are times when I am still prompted for the passphrase - this passphrase popup would also cause the scheduled task to get stuck running.Is there a way to bypass these two manual steps so that my script is fully automated?
Follow up question: Does the -d
option accept wildcard characters so that I can just decrypt any found file with a .pgp extension, and am I able to use the -o
option to output a .txt file of the same name as the .pgp file?
--passphrase-fd
option should be used with file descriptor (i.e. number like 3, 4, 5 and so on), not the password string. You should use --passphrase
option, adding --pinentry-mode=loopback
. Currently most likely it works since password is asked via popup and cached.
-d
with wildcards doesn't work, however you may use simple script to iterate over all files with pgp extension