Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git uses wrong subkey for signing commits with GPG key

Tags:

git

gnupg

I have an issue with git and signing commits with GPG key.

I have a master key (used for certification only). I've created two subkeys (only for signing) per computer. I've added public key to Github, configured git by using user.signingKey configuration option.

The issue is that git seems to be ignoring the configuration option and uses the newest subkey all the time (the latest on the list gpg --list-secret-keys EMAIL).

I've checked it on two environments, same issue. I'm using the following git version: git version 2.15.1

Any clues?

like image 257
Andrzej Ośmiałowski Avatar asked Oct 21 '25 12:10

Andrzej Ośmiałowski


2 Answers

To use a specific subkey, KEYID must be appended with !. So the configuration should look like the following:

[user]
    name = Andrzej Ośmiałowski
    email = [email protected]
    signingKey = KEYID!

Many thanks to Todd Zullinger to provide the solution on Git mailing list.

like image 110
Andrzej Ośmiałowski Avatar answered Oct 23 '25 03:10

Andrzej Ośmiałowski


The git commit man page describes:

-S[] --gpg-sign[=] GPG-sign commits. The keyid argument is optional and defaults to the committer identity; if specified, it must be stuck to the option without a space.

Would it help to always specify the sign key on git commit?`

It could be an issue on the git suite (Can you check on their issue tracker?

EDIT: Also maybe this is worth a try.

like image 30
Hassia Biker Avatar answered Oct 23 '25 01:10

Hassia Biker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!