gpg: decryption failed: No secret key

Mangesh Sathe picture Mangesh Sathe · Apr 20, 2017 · Viewed 38.9k times · Source

I am not able to decrypt my file without secret key. I know this question is asked on this before, solutions on this question did not help me.

This is my problem's scenario. This error I receive on command prompt while using --decrypt command.

gpg: decryption failed: No secret key

I have public key and a passphrase with me. I have used following commands to check if there is secret key or not.

• gpg --list-secret-keys

• gpg --list-keys

Both the above commands returned blank result(no error). so I decided to import public key with --import .

• gpg --import "C:\PATH\TO_MY_PUBLIC_KEY"

After --import command I can see public is imported. I could not find the way to deal with secret key. Is there any way I can find secret key or create new secret key.

Answer

Eliot Sykes picture Eliot Sykes · Mar 18, 2019

I also received blank output from the same 2 commands:

gpg --list-secret-keys
gpg --list-keys

I had reason to suspect this was to do with recent changes to the ~/.gnupg/pubring.kbx file, which lead me to run the following 2 commands to re-import missing keys:

Re-import missing secret keys:

gpg --import < ~/.gnupg/secring.gpg

Re-import missing public keys:

gpg --import < ~/.gnupg/pubring.gpg