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.Gpg4winor download and install manually - Start Kleopatra and generate or import keys
- Insert links to
gpg.exeinside 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.
there must be a bit more to this than that. at least on my ubuntu wsl, I didn't manage to get this running.
afaict, it would require moving my config files into
C:\Users\joelg\AppData\Roaming\gnupgregarding sshcontrol and gpg-agent.confDid you have these configured beforehand by any chance?
alternatively, I was using a "normal" linux setup with the pinentry set to the gnome3 packaged one. which i think is the default solution for wsl.