Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I can't sign commits from IntellIJ on windows using git from WSL2

Ok, so I have installed WSL2 Ubuntu on my Windows 10 pc. I'm trying to sign a commit from intellij (running as admin) installed on windows, and I'm using the git binary from the WSL2 vm, I have configured the gpg and git stuff in both windows and wsl, but I don't know why this is not working...

Here is a screenshot of the gpg signing working on the wsl vm. gpg working on wsl2

And here I have another picture of the gpg signing working on the windows terminal.

gpg working on windows

The dialog showed successfully on both terminals asking for my passphrase. Using the git cli the gpg key works:

manual commit working

And this is the error I get:

error on intellij

like image 505
Francisco Solis Avatar asked Oct 26 '25 02:10

Francisco Solis


1 Answers

After some more research I found a workaround:

I found this comment in the YouTrack site. Which led me to this stackoverflow post. The workaround/solution is the following:

Edit the ~/.gnupg/gpg-agent.conf inside your WSL setup and add the following line (or replace it if you already had a config with the same key):

This config will tell gpg to use the windows gui instead of the cli when asking for your passphrase

pinentry-program "/mnt/c/Program Files (x86)/GnuPG/bin/pinentry-basic.exe"

You can keep the program path to the pinentry-basic.exe (that's the default one), but if you have it under another location make sure to change it.

After that you can try the following command and check that the windows pinentry dialog shows up:

This command will sign the text "test" and will ask you for your key passphrase.

echo "test" | gpg --clearsign
like image 178
Francisco Solis Avatar answered Oct 27 '25 16:10

Francisco Solis



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!