USB/IP basically forwards USB over IP/Network, as the name implies. Forwarding or sharing sockets, or similar, is an absolute nightmare, so this enables a quick and easy operation.
The only downside is that the device won’t be available on Windows anymore. This is either the case while the device is attached, or even as long as it’s bound (see below for further explanation). This I can live with, as my whole development environment lives within WSL anyway.
Install
Attention
You need to perform the Windows installation in addition to the distro’s specific instructions.
Windows
First, you need to install the usbipd-win software on the Windows side. Some GUI tools automatically install this.
You can also run (from an elevated prompt)
winget install usbipd
Tip
Make sure to reopen any shell/terminal and check that
uspipd.exe
is available on yourPATH
.
Set up
Note
You might need to perform some or even all of the following steps using elevated rights.
GUI
The process can be greatly simplified, by installing downloading wsl-usb-manager on the Windows side.
Note
This GUI does not automatically install
usbipd-win
! Please download the installer from the release page and install it.
You can do everything you desire from within the GUI, even set up auto attachments, without a hassle.
CLI
First, list available devices using
usbipd.exe list
Take note of the BUSID
of the desired (smart card) device.
Tip
You can also use the Hardware ID (
VID:PID
column) by using the-i
flag instead of the-b
one.
Then simply execute
usbipd.exe bind -b BUSID
Replace
BUSID
: the one you took note of earlier.
Note
It might be necessary to force this operation with the
-f
flag, in which case the device will be unavailable under Windows until you perform anunbind
.
Now the only thing left to do is attaching the smart card to WSL
usbipd.exe attach -w -b BUSID
You can even have it auto-attached with
usbipd.exe attach -w -a -b BUSID
Note
The
bind
procedure is persistent between reboots. Theattach
procedure however isn’t, necessitating a reattachement.This also means forcing the
bind
using-f
makes it unavailable until you explicitly do anunbind
, whenattach
on the contrary, reinstates control to Windows whenever the device is no longer connected to WSL.
Tip
You can easily check if this worked by observing the
usbipd.exe
command output, or by utilizinglsusb
from theusbutils
package.
FIDO2
Despite all this, some utilities, for example ssh-keygen
, utilize a direct smart card access using, e.g., the /dev/hidraw
devices the USB/IP setup produces.
For that to work, I had to set up a udev rule.