Signing with GPG in Windows System for Linux (WSL2) does not work smoothly out of the box. Notably, when using a TTY-based pinentry, signing in Visual Studio Code does not work at all.
- Install Gpg4Win:
winget install -e GnuPG.Gpg4win
or download and install manually - Start Kleopatra and generate or import keys
- Insert links to
gpg.exe
inside of WSL:sudo ln -s /mnt/c/Program\ Files\ \(x86\)/GnuPG/bin/gpg.exe /usr/local/bin/gpg sudo ln -s gpg /usr/local/bin/gpg2
- That's it! Git and other GPG commands will now use the GPG installed in Windows, which has access to the GPG agent from Gpg4Win, and uses its graphical pinentry for passphrases.
This gpg
should take precedence over any gpg installed on the system. Verify this with command -v gpg
.
If this is not /usr/local/bin/gpg
, check $PATH
for the order of precedence on your system, and create the link in a directory that precedes (is left of) /usr/bin
or wherever the package manager installed GPG.