Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gpg: decryption failed: Bad session key

Tags:

gnupg

I'm trying to decrypt a file using gpg and getting this error:

$ gpg --no-tty --batch --verbose --decrypt --passphrase foo file.enc
Version: GnuPG v1.4.11 (GNU/Linux)
gpg: armor header: 
gpg: CAST5 encrypted data
gpg: encrypted with 1 passphrase
gpg: decryption failed: Bad session key

I tried to reload the gpg agent, no luck:

$ gpgconf --reload gpg-agent

How to solve that?

like image 342
yegor256 Avatar asked May 19 '15 06:05

yegor256


2 Answers

For the record, if somebody will encounter this problem, too:

The problem was, that the encryption was done using gpg version 1.4.11 and the decryption was using gpg version 2.0.22.

After upgrading the encryption to gpg2 (2.0.17), everything worked fine.

like image 187
Udo Klimaschewski Avatar answered Nov 16 '22 05:11

Udo Klimaschewski


I found this, which seems to be the magic that I could not find anywhere else:

Try adding --pinentry-mode loopback to your command. Maybe there is a problem with your installation / pinentry program so that it does not start or you are accidentally using a dummy / test pinentry which provides the wrong passphrase.

like image 12
Gerald Lotto Avatar answered Nov 16 '22 06:11

Gerald Lotto