Reputation: 49
Added a gpg key to sign commits.
After all the configuration is done, I am able to sign via git cli.
But when I commit using vscode it opens a terminal window so I can enter my key password. The window appears a little buggy and does not accept the password and returns the error in vscode:
error: gpg failed to sign the data
When I restart gpg-agent and manage to commit via cli.
When I type the password through the cli, it is stored in that section of the terminal and I manage to commit through vscode. When you close the section, the error returns.
I'm using wsl2 with linux Ubuntu 20
Upvotes: 1
Views: 3888
Reputation: 75
Also, when using gitconfig files to enable GPG signing, make sure to use the long key from when you created your gpg key i.e.:
[user]
email = [email protected]
name = My Name
signingkey = ########################################
[gpg]
program = gpg
[commit]
gpgsign = true
Which should work if you get errors like not being able to sign because a private key does not exist.
If you want to find out these credentials, go to git bash and hit the gpg --list-secret-keys --keyid-format=long
command which should output something along the lines of:
sec rsa4096/SHORT_KEY_ID yyyy-mm-dd [SC] [expires: yyyy-mm-dd]
LONG_KEY_ID
uid [ultimate] My Name (comment) <[email protected]>
ssb rsa4096/SHORT_KEY_ID yyyy-mm-dd [E] [expires: yyyy-mm-dd]
You will want to use the LONG_KEY_ID for the signing key!
Hope that helps.
Signed, 9662e103-129a
Upvotes: 0
Reputation: 49
I found a solution...
Steps required:
Install GPG4Win from https://www.gpg4win.org. Nothing other than the default gnupg is required, but I installed Kleopatra too in case it came in handy elsewhere.
Edit ~/.gnupg/gpg-agent.conf and change the pinentry
pinentry-program "/mnt/c/Program Files (x86)/GnuPG/bin/pinentry-basic.exe"
Upvotes: 0
Reputation: 51780
I guess your issue is :
To confirm that having the correct environment works, you can try the following :
You can check the environment before and after starting your gpg-agent to confirm that variables do get updated (in bash, this simply means running env
or env | sort
from the command line).
Upvotes: 0