2
gpg: AES256 encrypted data gpg: encrypted with 1 passphrase gpg: decryption failed: Bad session key 

I am doing decryption by following command:

gpg --passphrase-file /path/to/key --output /path/to/output --decrypt /path/to/file 

It again asks for the passphrase and results in above mentioned error.

When I fed this error to a search engine, I encountered many questions which mentioned the last line 'Bad session key' and most of their answers said it may be because encryption was done by GnuPG version 1 and decryption is done by GnuPG version 2. However, in this case both the version are 2, and also I didn't find this exact same error in any question.

I am doing this on Termux on android.

2
  • 1
    Was the data encrypted with an older version of GnuPG? Commented Jan 12, 2019 at 8:21
  • @Kusalananda i don't know the exact release but passphrase file mentioned version: GnuPG2 Commented Jan 12, 2019 at 17:03

1 Answer 1

2

I have encountered this error when using the wrong password to decrypt a file with GPG. I recommend checking the passphrase file to be sure that you have the correct content and ONLY the correct content, no extra spaces or newline characters. Also ensure that the read permission for the file is granted to your user, as that may also be a possible cause of the problem.

If that doesn't work, try adding the --batch --pinentry-mode loopback flags before --passphrase-file, so the resulting command in your case would look like the following:

gpg --batch --pinentry-mode loopback --passphrase-file /path/to/key --output /path/to/output --decrypt /path/to/file 

For more information about the flags in question, see this answer and the rest of the attached thread.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.