33

I am getting an error:

gpg: no default secret key: No secret key
gpg: [stdin]: clearsign failed: No secret key

My secret keys are available to GPG.

Eric Platon
  • 9,819
  • 6
  • 41
  • 48
Cindrella
  • 1,671
  • 7
  • 27
  • 47

4 Answers4

24

If gpg --list-keys returns nothing, gpg --generate-key solves the problem.

Timofey Gorshkov
  • 4,987
  • 6
  • 41
  • 66
16

This confusing error message wasted me days of time. I deploy my maven project to maven central, which was always working, but suddenly it gives this message without prompting the passcode. Searched through all the answers didn't solve my problem. Eventually, I found out my key is expired.

gpg --list-keys

So I need to change the expiration by using gpg --edit-key

And make sure to update both keys.

Johannes Jander
  • 4,974
  • 2
  • 31
  • 46
Jianwu Chen
  • 5,336
  • 3
  • 30
  • 35
5

It might be difference between gpg1 and gpg2. The secret keys are stored in different ways. You may have both of them.

Try

which gpg gpg2

If you do have both, run:

gpg2 --list-secret
gpg --list-secret

You maybe able to tell that one works, another does not.

Ding-Yi Chen
  • 2,830
  • 33
  • 27
  • 1
    I have both installed. Neither listed any secret keys until I issued `gpg2 --rebuild-keydb-caches`. Now they list my keys again. My maven sonatype deploy still doesn't work, but I think this is a step in the right direction. – GlenPeterson Sep 10 '17 at 15:59
0

Here's the answer: I am using latest gnupg version , but I have to use 0.44 gnupg interface version. I have reinstalled the gnupg.

Then no compilation errors were found. I am able to sign my message. but not able to send the request. The problem is I have not installed LWP::Protocol::Https module which is used by "Useragent" to send the request.( i came to know this that i have not installed the module by keeping simple print statements which shown the problem that LWP::Protocol::Https is not found). So i have installed LWP::Protocol::Https module through cpan. And i am good to go. Finally all is set :-)

Cindrella
  • 1,671
  • 7
  • 27
  • 47