Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No secret key when signing with git

Tags:

git

gnupg

After setting

$ gpg --list-keys
/home/pablo/.config/gnupg/pubring.gpg
-------------------------------------
pub   rsa4096/46F257F2 2014-09-16 [expires: 2015-09-16]
uid       [ultimate] Pablo Olmos de Aguilera Corradini (Personal) <[email protected]>

And putting the info on gitconfig:

[user]
    name = Pablo Olmos de Aguilera Corradini
    email = [email protected]
    signinkey = 46F257F2
[commit]
    gpgsign = true

I get:

gpg: skipped "Pablo Olmos de Aguilera Corradini <[email protected]>": No secret key
gpg: signing failed: No secret key
error: gpg failed to sign the data
fatal: failed to write commit object

As you can see the keys actually exists (they also appears when running gpg --list-secret-keys). If I remove everything from gitconfig, and try to do it only with -S, I get the same error, which makes me think that git is passing my user name and email to gpg, and the uid includes the "comment" (Personal), so it doesn't found any:

$ gpg --list-keys "Pablo Olmos de Aguilera Corradini <[email protected]>"
gpg: error reading key: No public key

I'm not sure if this is a bug from git, or it is the expected result and I'm missing something :).

PS.- My guess is that I could create another uid but without a comment, and it should work.

like image 747
Pablo Olmos de Aguilera C. Avatar asked Dec 14 '14 18:12

Pablo Olmos de Aguilera C.


People also ask

How do I fix GPG signing failed no secret key?

To fix the encountered “gpg: decryption failed: No secret key” error you can install the “pinentry-tty” program and add it to the gpg-agent configuration file.

What is signing key in GitHub?

To sign commits associated with your account on GitHub, you can add a public GPG key to your personal account. Before you add a key, you should check for existing keys. If you don't find any existing keys, you can generate and copy a new key.

How do you check if git commit is signed?

If you're interested in signing commits directly instead of just the tags, all you need to do is add a -S to your git commit command. To see and verify these signatures, there is also a --show-signature option to git log .


1 Answers

There is a typo in your gitconfig. Should be signingkey, not signinkey

like image 80
Martin Avatar answered Oct 20 '22 10:10

Martin