Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GPG fails during git commit

I have gpg setup on my local machine and most of the time it works. But sometimes the commit takes about a minute and then fails. When commiting something I just get the output:

gpg: DBG: Not using CREATE_BREAKAWAY_FROM_JOB flag
gpg: can't connect to the agent: IPC connect call failed
gpg: keydb_search failed: No agent running
gpg: skipped "<mykeyid>": No agent running
gpg: signing failed: No agent running
error: gpg failed to sign the data
fatal: failed to write commit object

So I thought maybe there is no gpg agent running and I started one:

>gpg-agent --daemon --verbose
gpg-agent: a gpg-agent is already running - not starting a new one

Someone suggested on different threads that maybe my gpg versions mismatch or target different installations:

>gpg --version
gpg (GnuPG) 2.2.23-unknown
libgcrypt 1.8.7

>gpg-agent --version
gpg-agent (GnuPG) 2.2.23-unknown
libgcrypt 1.8.7

So the versions seem to be the same and the installation directory seems to be ok too:

>which gpg
/usr/bin/gpg

>which gpg-agent
/usr/bin/gpg-agent

For additional information: I'm running Windows 10 with gpg4win 3.1.16, commit using sublime merge or git cli.

>gpg --list-keys --keyid-format LONG
/c/Users/micha/.gnupg/pubring.kbx
---------------------------------
pub   ed25519/<mykeyid> 2021-03-02 [SCA] [expires: 2023-03-02]
      <someotherid>
uid                 [ unknown] <mymail1>
uid                 [ unknown] <mymail2>
sub   cv25519/<someotherid> 2021-03-02 [E] [expires: 2023-03-02]
like image 891
Michael Chen Avatar asked May 31 '26 04:05

Michael Chen


1 Answers

I guess it's because your key is untrusted. GPG by default does not use an untrusted key.

Solution #1: Edit key trust

You can edit the key like that, with trust command:

gpg --edit-key <fingerprint>
Secret key is available.

sec  rsa4096/****************
     created: 2022-10-24  expires: never       usage: SC  
     trust: unknown       validity: full
ssb  rsa4096/****************
     created: 2022-10-24  expires: never       usage: E   
[  unknown  ] (1). John Doe (Test Key) <[email protected]>
gpg> trust
Please decide how far you trust this user to correctly verify other users' keys
(by looking at passports, checking fingerprints from different sources, etc.)

  1 = I don't know or won't say
  2 = I do NOT trust
  3 = I trust marginally
  4 = I trust fully
  5 = I trust ultimately
  m = back to the main menu

Your decision?
4

Solution #2: Sign the key

When you sign a key with your ultimately trusted key, its trust is automatically set as full.

gpg --sign-key <fingerprint>

Note that this action creates an exportable signature for another person's key. It is not recommended if you don't really trust the person.

Hope that helps!


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!