DEV Community

Discussion on: The ultimate guide to Yubikey on WSL2 [Part 2]

Collapse
 
byteduty profile image
Colin Docherty • Edited

Any suggestion on debugging if gpg-agent keeps starting on Ubuntu wsl, when I do gpg --card-status ?
I've followed the guide multiple times, and I repeated it also in the Debian wsl.
I can successfully use "ssh-add -L" and I can access my Yubikey stored ssh key no problem.
However, when I do gpg --card-status I get a delay, then:

$ gpg --card-status
gpg: can't connect to the agent: End of file
gpg: OpenPGP card not available: No agent running

pstree then shows gpg-agent running, even though it wasn't previously.

This is the state of processes before I run gpg --card-status:

colin 25 0.0 0.0 6968 1832 ? Ss 11:50 0:00 socat UNIX-LISTEN:/home/colin/.ssh/agent.sock,fork EXEC:/home/colin/.ssh/wsl2-ssh-pageant.exe
colin 29 0.0 0.0 6968 1776 ? Ss 11:50 0:00 socat UNIX-LISTEN:/home/colin/.gnupg/S.gpg-agent,fork EXEC:/home/colin/.ssh/wsl2-ssh-pageant.exe --gpg S.gpg-agent

This is the state of process after I run gpg --card-status

$ gpg --card-status
gpg: can't connect to the agent: End of file
gpg: OpenPGP card not available: No agent running
colin@letham:~$ ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 2424 1032 ? Sl 11:50 0:00 /init
root 7 0.0 0.0 1752 68 ? Ss 11:50 0:00 /init
root 8 0.0 0.0 1752 76 ? S 11:50 0:00 /init
colin 9 0.0 0.0 10040 5048 pts/0 Ss 11:50 0:00 -bash
colin 25 0.0 0.0 6968 1832 ? Ss 11:50 0:00 socat UNIX-LISTEN:/home/colin/.ssh/agent.sock,fork EXEC
colin 29 0.0 0.0 6968 3380 ? Ss 11:50 0:00 socat UNIX-LISTEN:/home/colin/.gnupg/S.gpg-agent,fork E
colin 583 0.0 0.0 82952 972 ? Ss 11:52 0:00 gpg-agent --homedir /home/colin/.gnupg --use-standard-s
colin 597 0.0 0.0 10620 3308 pts/0 R+ 11:52 0:00 ps aux

gpg --card-status is running fine in the Windows terminal.

I'm running wsl2, on Windows 11, on a new Surface Pro 8. I've also managed to previously get this running on my HP Running Windows 11 a few weeks ago, although this was probably using instructions elsewhere.

Collapse
 
phillipmcmahon profile image
Phillip

I am also seeing this same error on a new install of Windows 10. On that side of things all is working fine, gpg and ssh all recognise my yubikey and I am prompted for my PIN etc.

Prior to my rebuild, I had this working on my WSL Ubuntu instance but now getting this error. socat, scdaemon, ss, etc. all installed. ssh works and I am prompted for my PIN, just no joy at all with gpg.

"gpg: selecting card failed: No such device
gpg: OpenPGP card not available: No such device"

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 1052 668 ? Sl 11:00 0:00 /init
root 8 0.0 0.0 900 84 ? Ss 11:00 0:00 /init
root 9 0.0 0.0 900 84 ? S 11:00 0:00 /init
phillip+ 10 0.0 0.0 10036 5004 pts/0 Ss 11:00 0:00 -bash
phillip+ 26 0.0 0.0 6968 1744 ? Ss 11:00 0:00 socat UNIX-LISTEN:/home/phillipmcmahon/.ssh/agent.sock,fork EXEC:/home/phillipmcmahon/.ssh/wsl2-ssh-pageant.exe
phillip+ 30 0.0 0.0 6968 3192 ? Ss 11:00 0:00 socat UNIX-LISTEN:/home/phillipmcmahon/.gnupg/S.gpg-agent,fork EXEC:/home/phillipmcmahon/.ssh/wsl2-ssh-pageant.exe --gpg S.gpg-agent
phillip+ 485 0.0 0.0 82952 2640 ? Ss 11:00 0:00 gpg-agent --homedir /home/phillipmcmahon/.gnupg --use-standard-socket --daemon
phillip+ 574 0.0 0.0 93772 3472 ? SLl 11:07 0:00 scdaemon --multi-server
phillip+ 578 0.0 0.0 10620 3192 pts/0 R+ 11:08 0:00 ps aux
phillip+ 579 0.0 0.0 10036 1700 pts/0 D+ 11:08 0:00 -bash

Collapse
 
ryanjaeb profile image
Ryan Jaeb

You may be running into this. With newer versions of gnupg4win the windows socket file (S.gpg-agent) ends up in ...\AppData\Local\..., but wsl2-ssh-pageant is expecting ...\AppData\Roaming\....