Git signing doesn't ask for my passphrase

I tried to sign my commits with the git commit -S command, but it does not work without asking for my passphrase for my GPG key.

Error:

 error: gpg failed to sign the data fatal: failed to write commit object 

I noticed that if I ran the following command before git commit -S :

 gpg -o /dev/null --local-user MY_KEY_ID -as <(echo 1234) && echo "The correct passphrase was entered for this key" 

... everything works well, and my commits are correctly signed. I think this is because my passphrase is cached, but this is not the behavior that I expect.

I was hoping Git would request my passphrase every time I want to sign commits or tags.

The command "unlock my key" was found on this issue: How to use the gpg command line correctly to check the passphrase

+5
source share
1 answer

You probably need to tell pinentry , the gpg software uses to request your password where you need it.

 export GPG_TTY=$(tty) git commit -S 

If this works, I would recommend exporting GPG_TTY to your shell 'rc' file.

gpg-agent documentation regarding GPG_TTY

+2
source

Source: https://habr.com/ru/post/1276230/


All Articles