5

I received an file encrypted with the public key I generated but I can't get it to decrypt.

Steps:

  1. gpg --gen-key default options
  2. gpg --export -a <email> > pub.key
  3. sent the pub.key
  4. received the encrypted file
  5. cat <file> | gpg

The error:

$ cat cred.gpg | gpg
gpg: key 71980D35: secret key without public key - skipped
gpg: encrypted with RSA key, ID 0D54A10A
gpg: decryption failed: secret key not available

However, the secret key DOES exist in my keyring and the public key i generate from it matches the fingerprint of the pub.key i sent to my coworker.

$ gpg --list-secret-keys 
/home/jcope/.gnupg/secring.gpg
------------------------------
sec   2048R/71980D35 2016-03-04
uid                  me <email>
ssb   2048R/0D54A10A 2016-03-04

Checking the fingerprint

    $ gpg --with-fingerprint pub.key 
    pub  2048R/AF0A97C5 2016-03-04 me <email>
          Key fingerprint = 17A4 63BF 5A7D D3B2 C10F  15C0 EDD6 4D8A AF0A 97C5
    sub  2048R/1103CA7C 2016-03-04
$ gpg --fingerprint | grep 17a4 -i
      Key fingerprint = 17A4 63BF 5A7D D3B2 C10F  15C0 EDD6 4D8A AF0A 97C5

I'm a gpg newby and at a loss for why this isn't working. It seems like the most standard operation.

  • Note the error message: it doesn't say that the secret key is missing (it isn't), it says the public key is missing. Did it get deleted by accident? Try re-importing the public key from a public keyserver or somewhere? – Celada Mar 5 '16 at 18:24
  • @celada, re-importing the pubkey will be of no use, since this has to do with the private key. – gerhard d. Mar 5 '16 at 18:52
  • @gerhardd. my reading of the error message "secret key without public key" is that it's not to do with the private key. – Celada Mar 5 '16 at 18:53
  • try 'gpg --edit-key <PRIVKEY_ID>' and paste the output here. It may have expired, or been disabled... – gerhard d. Mar 5 '16 at 18:53
  • @Celada ah ha! That was it :) I was assuming that if I could export a public key from my secret, then THAT was my pub key. I copied down my original pub key from the server, imported that, and it worked! I still don't get what the difference is between the first pub and the exported one. – jonRH Mar 5 '16 at 18:55
2

Note the error message: it doesn't say that the secret key is missing (it isn't), it says the public key is missing.

gpg: key 71980D35:secret key without public key- skipped

In RSA, some numbers (d, p, q, u) are private and others (n, e) are public. Only the 2 public numbers are required for encryption and signature verification while all 6 numbers are required in order to decrypt and sign. So for the latter operations, you actually need both the secret and public keys.

Did the public key get deleted from the pubring by accident?

You can try re-importing the public key. Since the public key is the one that is distributed widely, it should be easy to re-obtain a copy of it.

  • You're correct, fetching the pub-key from the keyserver and importing it did the trick. I'm a little confused as to what the difference is between that public key generated when i did gpg --gen-key and the ones I generated later using gpg --export -a > pub.key Shouldn't they have been identical? And if so, why then was the pub key missing? – jonRH Mar 5 '16 at 19:28
  • Yes, I think they should be identical. I can't guess the root cause of what exactly happened to cause this problem. – Celada Mar 5 '16 at 19:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.