Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git - gpg onto mac osx: error: gpg failed to sign the data

Tags:

git

macos

gnupg

I installed GPG from brew.

brew install gpg 

It is gnupg2-2.0.30_2.

When I commit, I do get a error message:

You need a passphrase to unlock the secret key for user: "Max Mustermann (mycomment) <[email protected]>" 2048-bit RSA key, ID 1111AAAA, created 2017-01-05   error: gpg failed to sign the data fatal: failed to write commit object 

I used the command:

gpg --list-secret-keys | grep ^sec 

and it gives me back:

sec   2048R/1111AAAA 2017-01-05 

Then I used this command:

git config --global user.signingkey 1111AAAA 

commit gives me back the same error message.

How can I solve this problem?

like image 900
Mondy Avatar asked Jan 06 '17 09:01

Mondy


People also ask

How do I add a GPG key to my keychain?

After you receive a public key from somebody, you can import into your keychain. Select Import from the menu in GPG Keychain Access and select the public key that was sent to you. After importing a public key, you should verify that the key actually belongs to the person that you believe it belongs to.

How do I turn off Commit sign?

You can disable this by running git config commit. gpgsign false This sets the configuration locally instead of globally.


1 Answers

If you’re not getting prompted at all for a passphrase, the solution may just be to install a program to facilitate that. The most common is pinentry.

brew install pinentry-mac 

So installing that and trying again may get things working. But if not, another thing to do is make sure git it using/finding the right GPG program. These days you really should be using gpg2, so if you don’t already have that installed, do:

brew install gnupg2 

And then, to tell git that’s the GPG program want to you, this:

git config --global gpg.program gpg2 

At that point, try your commit again and things may just work.

But if not, then try this:

echo "pinentry-program /usr/local/bin/pinentry-mac" >> ~/.gnupg/gpg-agent.conf 

…or, more robustly:

echo "pinentry-program $(which pinentry-mac)" >> ~/.gnupg/gpg-agent.conf 

…and then try again.

And you may also need to stop gpg-agent:

gpgconf --kill gpg-agent 

You don’t need to manually restart it — it will get restarted automatically when it’s needed.

Note: Some comments below mention needing to reboot after making changes — but it seems likely the only effect that has it is to cause gpg-agent to be restarted. So manually killing gpg-agent as described above should be sufficient.

like image 194
sideshowbarker Avatar answered Oct 12 '22 22:10

sideshowbarker