In git commits (gpg), git command always asks for passphrase while gpg-agent is running.

I launch gpg-agent with

$ eval `gpg-agent -s --enable-ssh-support --daemon --write-env-file $HOME/.gpg-agent-info`

Then I open another terminal and check it's running:

$ cat ~/.gpg-agent-info
$ ps -u $USER | grep gpg-agent
28539 ?        00:00:00 gpg-agent
/tmp/gpg-w2HH4r/S.gpg-agent:28539:1 /tmp/gpg-QQTJCD/S.gpg-agent.ssh 28539
$ echo test | gpg-aes -t D2FA51BD --use-agent | gpg --use-agent

The first '....' says that it's needed a passphrase and gpg-agent launchs pinentry-gtk-2. The last '....' says that gpg is signing with the key ID.

Running again the same command don't asks for passphrase


But when running git, gpg asks for the passphrase in the command line, not gpg-agent with pinentry:

$ echo test >> test.txt ; git add test.txt ; git commit -S -m "test"
(intro passphrase)

Running again (and again...) the same command always asks for passphrase (to the same key ID).

My .gitconfig only has set the user name and email. Both commands (gpg and git) asks for the same key ID. Calling gpg with --use-agent works fine (without it not), but git has no options to pass to gpg (only user config values in .gitconfig); and the environment is correct.

Logging gpg-agent with debug-level 8 only shows activity with gpg command, but nothing with git.

I'm using gnupg 1.4.12 and gpg-agent 2.0.19 (Debian Wheezy stable, official repos). I've cloned git from github repo, compiled and installed locally the current versión (2.3.0.rc1.30.g76afe74) with the same results.

I've checked my configs but I've no idea what kind of problem is this. Any suggestion?



Silly me... Setting option use-agent in gpg.conf solves the issue.

Git doesn't check if gpg-agent is running and gpg needs to be called with the option --use-agent.

I must change my default GPG behavior (options)... and use --no-use-agent in other scenarios.

  • I have use-agent on my conf file but it is still not called by git commands. – Soullivaneuh Mar 10 at 0:47

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.