Gpg-agent cannot find key card in Arch Linux WSL2

Hello,
I’m running Arch Linux WSL2, installed usbipd-win to share locally USB devices to WSL2.

The smartcard is accessible in Arch Linux:

❯ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 20a0:4108 Clay Logic Nitrokey Pro
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub

Then I configured GnuPG according to Arch wiki.

Running gpg --card-status fails with error:

❯ gpg --card-status
gpg: WARNING: unsafe permissions on homedir '/home/thomas/.gnupg'
gpg: selecting card failed: Service is not running
gpg: OpenPGP card not available: Service is not running

However running sudo gpg --card-status the relevant information is displayed correctly.

Imo this is pointing to a permission issue.
Therefore I have installed /etc/udev/rules.d/41-nitrokey.rules from here, however this is not fixing the issue.

Can you please advise how to fix this issue?
Is my assumption wrong that this must be a addressed with a udev-rule?

I created this udev-rule based on output of udevadm info --attribute-walk --path=/devices/platform/vhci_hcd.0/usb1/1-1/1-1:1.0/0003:20A0:4108.0002

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/platform/vhci_hcd.0/usb1/1-1/1-1:1.0/0003:20A0:4108.0002':
    KERNEL=="0003:20A0:4108.0002"
    SUBSYSTEM=="hid"
    DRIVER==""
    ATTR{report_descriptor}==""

  looking at parent device '/devices/platform/vhci_hcd.0/usb1/1-1/1-1:1.0':
    KERNELS=="1-1:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="usbhid"
    ATTRS{authorized}=="1"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bInterfaceClass}=="03"
    ATTRS{bInterfaceNumber}=="00"
    ATTRS{bInterfaceProtocol}=="00"
    ATTRS{bInterfaceSubClass}=="00"
    ATTRS{bNumEndpoints}=="01"
    ATTRS{supports_autosuspend}=="1"

  looking at parent device '/devices/platform/vhci_hcd.0/usb1/1-1':
    KERNELS=="1-1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{authorized}=="1"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bDeviceClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bMaxPower}=="100mA"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bNumInterfaces}==" 2"
    ATTRS{bcdDevice}=="0101"
    ATTRS{bmAttributes}=="80"
    ATTRS{busnum}=="1"
    ATTRS{configuration}==""
    ATTRS{devnum}=="3"
    ATTRS{devpath}=="1"
    ATTRS{idProduct}=="4108"
    ATTRS{idVendor}=="20a0"
    ATTRS{ltm_capable}=="no"
    ATTRS{manufacturer}=="Nitrokey"
    ATTRS{maxchild}=="0"
    ATTRS{product}=="Nitrokey Pro"
    ATTRS{quirks}=="0x0"
    ATTRS{removable}=="unknown"
    ATTRS{remove}=="(not readable)"
    ATTRS{rx_lanes}=="1"
    ATTRS{serial}=="0000000000000000000080CE"
    ATTRS{speed}=="12"
    ATTRS{tx_lanes}=="1"
    ATTRS{urbnum}=="13"
    ATTRS{version}==" 1.10"

  looking at parent device '/devices/platform/vhci_hcd.0/usb1':
    KERNELS=="usb1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{authorized}=="1"
    ATTRS{authorized_default}=="1"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bMaxPower}=="0mA"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bcdDevice}=="0515"
    ATTRS{bmAttributes}=="e0"
    ATTRS{busnum}=="1"
    ATTRS{configuration}==""
    ATTRS{devnum}=="1"
    ATTRS{devpath}=="0"
    ATTRS{idProduct}=="0002"
    ATTRS{idVendor}=="1d6b"
    ATTRS{interface_authorized_default}=="1"
    ATTRS{ltm_capable}=="no"
    ATTRS{manufacturer}=="Linux 5.15.133.1-microsoft-standard-WSL2 vhci_hcd"
    ATTRS{maxchild}=="8"
    ATTRS{product}=="USB/IP Virtual Host Controller"
    ATTRS{quirks}=="0x0"
    ATTRS{removable}=="unknown"
    ATTRS{remove}=="(not readable)"
    ATTRS{rx_lanes}=="1"
    ATTRS{idVendor}=="20a0"
    ATTRS{ltm_capable}=="no"
    ATTRS{manufacturer}=="Nitrokey"
    ATTRS{maxchild}=="0"
    ATTRS{product}=="Nitrokey Pro"
    ATTRS{quirks}=="0x0"
    ATTRS{removable}=="unknown"
    ATTRS{remove}=="(not readable)"
    ATTRS{rx_lanes}=="1"
    ATTRS{serial}=="0000000000000000000080CE"
    ATTRS{speed}=="12"
    ATTRS{tx_lanes}=="1"
    ATTRS{urbnum}=="13"
    ATTRS{version}==" 1.10"

  looking at parent device '/devices/platform/vhci_hcd.0/usb1':
    KERNELS=="usb1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{authorized}=="1"
    ATTRS{authorized_default}=="1"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bMaxPower}=="0mA"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bcdDevice}=="0515"
    ATTRS{bmAttributes}=="e0"
    ATTRS{busnum}=="1"
    ATTRS{configuration}==""
    ATTRS{devnum}=="1"
    ATTRS{devpath}=="0"
    ATTRS{idProduct}=="0002"
    ATTRS{idVendor}=="1d6b"
    ATTRS{interface_authorized_default}=="1"
    ATTRS{ltm_capable}=="no"
    ATTRS{manufacturer}=="Linux 5.15.133.1-microsoft-standard-WSL2 vhci_hcd"
    ATTRS{maxchild}=="8"
    ATTRS{product}=="USB/IP Virtual Host Controller"
    ATTRS{quirks}=="0x0"
    ATTRS{removable}=="unknown"
    ATTRS{remove}=="(not readable)"
    ATTRS{rx_lanes}=="1"

but the issue is not solved.

❯ cat /etc/udev/rules.d/41-nitrokey.rules
SUBSYSTEM=="hid", SUBSYSTEMS=="usb", ATTRS{manufacturer}=="Nitrokey", ATTRS{product}=="Nitrokey Pro", MODE="0660", TAG+="uaccess"

THX

Looks like you might have a problem related to polkit and pcsc-lite integration

There are also other threads on this forum, just search for “polkit”.