I have batch encrypted some backup files using a script. The OS is CentOS 7 and the current version of gpg is 2.0.22. The important parts of the script are:
enter code here`echo Enter passphrase
read PASS
for sourcefile in $(find /quitelarge/upload/proton/ -name *.gz); do
echo $sourcefile
destfile=$(echo $sourcefile | sed '1 s;/quitelarge/upload/proton;/quitelarge/upload/mega;')
gpg --batch --passphrase "$PASS" -o $destfile.gpg -c $sourcefile
done
When I attempted to decrypt one of the files this happened:
gpg -d agent.tar.gz.gpg
gpg: CAST5 encrypted data
gpg: encrypted with 1 passphrase
gpg: DBG: cleared passphrase cached with ID: SAEFA41D323D1BAE9
gpg: decryption failed: Bad session key
Yes, I did enter the correct passphrase. In researching this problem I have found reference to:
- Different version of gpg used to encrypt and decrypt - just tried encrypting/decrypting with the same version of gpg, same error
- Issue on Windoze with cr/lf being included in pass phrase - from what I read I do not think this is a Linux concern
I tested this process a year or more back and I could decrypt the backup files. perhaps something has changed in gpg (?) I am at a loss. Any suggestions?
TIA,
Ken
p.s. As CentOS 7 is getting rather old in the tooth I tried decrypting the files on a Linux Mint 20.3 machine with gpg 2.2.19. Same issue. I have a suspicion that this may be related to the fact that gpg was upgraded at some point to gpg2. which gpg points to a link to gpg2.
I DID run the test script against a new plaintext file with the current gpg and then tried to decrypt. Same issue.
Asked by Ken-T
(11 rep)
Mar 22, 2022, 05:50 PM
Last activity: May 2, 2025, 06:08 PM
Last activity: May 2, 2025, 06:08 PM