Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GnuPG: "decryption failed: secret key not available" error from gpg on Windows [closed]

People also ask

What is gpg secret key?

The GPG key pair comprises two types of keys: Private and Public keys. The private GPG keys are encrypted and stored in the secret keyring, and public keys are maintained with certificates attesting to their trustworthiness in the public keyring.

How do I delete my gpg secret key?

gpg: use option “–delete-secret-keys” to delete it first. This means that if you have private key of a public key then you need to delete the private key first. Hope this helps. Thanks.

What is ELG key?

ELG-E refers to an ElGamal key which can only be used for encryption (not for signing), whereas ELG refers to an ElGamal key which can be used for both encryption and signing. The new GnuPG version should be able to work with ELG-E keys, so there's no need to generate new keys because of this.


You need to import not only your secret key, but also the corresponding public key, or you'll get this error.


when reimporting your keys from the old keyring, you need to specify the command:

gpg --allow-secret-key-import --import <keyring>

otherwise it will only import the public keys, not the private keys.


Yes, your secret key appears to be missing. Without it, you will not be able to decrypt the files.

Do you have the key backed up somewhere?

Re-creating the keys, whether you use the same passphrase or not, will not work. Each key pair is unique.


workmad3 is apparently out of date, at least for current gpg, as the --allow-secret-key-import is now obsolete and does nothing.

What happened to me was that I failed to export properly. Just doing gpg --export is not adequate, as it only exports the public keys. When exporting keys, you have to do

gpg --export-secret-keys >keyfile

One more cause for the "secret key not available" message: GPG version mismatch.

Practical example: I had been using GPG v1.4. Switching packaging systems, the MacPorts supplied gpg was removed, and revealed another gpg binary in the path, this one version 2.0. For decryption, it was unable to locate the secret key and gave this very error. For encryption, it complained about an unusable public key. However, gpg -k and -K both listed valid keys, which was the cause of major confusion.


The resolution to this problem for me, was to notify the sender that he did use the Public key that I sent them but rather someone elses. You should see the key that they used. Tell them to use the correct one.