USB/IP is a network-based device sharing mechanism, which can share the USB device connected to computer A (server side) to remote computer B (client side) through the network
There are many implementations (programs) of USB/IP. In addition to the free programs used below, there are also commercial programs:
- USB Network Gate
- FlexiHub
- VirtualHere
See this article for more about USB over Network
Server side (computer A, connected to the USB device)
Windows
PS : The open source software on windows selected in this article is usbip-win , and the installation and configuration method can also be found in the official README
Install
-
First download the official compiled software compression package and decompress it. If you want to compile it yourself, refer to the README of the official code
-
Double-click the file
usbip_test.pfx
to prepare the certificate for import. The certificate needs to be imported twice, respectively into "Trusted Root Certification Authorities" and "Trusted Publishers" -
Open CMD or PowerShell as an administrator , enter the directory where the software is located, and run the command to enable the test signature
bcdedit.exe /set TESTSIGNING ON
-
Open the port required by usbip: the default port is 3240, to the inbound port in the firewall
- You can also use other ports, and you need to use this port for subsequent configuration.
- You can also use other ports, and you need to use this port for subsequent configuration.
-
Restart the computer
-
(Optional) Download the latest usb.ids and replace the usb.ids file in the directory where the software is located.
- Each USB device has its own ID (similar to the IP address of the network), and usb.ids (similar to a DNS server) records the names corresponding to all known USB device IDs (divided into vendor names and device names, similar to website domain names) ), to facilitate subsequent quick identification of USB devices.
- However, because USB devices are constantly being released, the IDs of newer USB devices have not been recorded in usb.ids, so the words "unknown product" will be displayed in the subsequent identification process, indicating that they are in the usb.ids file. No related records. Don’t worry about it, it can be used if you can’t find the record, but it’s not convenient for us to identify it.
configuration
-
Open CMD or PowerShell as an administrator and enter the directory where the software is located
-
Connect the USB device to the computer, then use the command
.\usbip.exe list -l
to list all recognized USB devices- The display of "unknown product" is because there is no relevant record in the usb.ids file, which only affects your identification of the USB device and does not affect subsequent operations
- I have five USB devices shown here (each "-" means one device)
-
Find the USB device you want to share remotely, and record its busid in the format
[数字]-[数字]
- If it is not recognized, you can run the above commands before and after the USB device is connected
- Suppose the device I want to share remotely is the fourth USB device with the word SATA (my mobile hard disk), and its busid is
1-181
-
Bind the USB device to usbip
- Note that after binding, the local computer cannot use this USB device
.\usbip.exe bind -b [busid] # 例如我这儿就是 .\usbip.exe bind -b 1-181
-
Start the usbipd service
.\usbipd.exe -d -4 # 如果想用其他端口,且安装的时候配置过防火墙 .\usbipd.exe -d -4 -tPORT [端口]
-
After use, you can unbind the USB device with usbip
.\usbip.exe unbind -b [busid]
Then you need to go to "Devices and Printers", find the connected USB device, uninstall all "USB/IP STUB", and finally re-plug the USB device
-
If you don't need usbip, you can close the test signature, and then restart
bcdedit.exe /set TESTSIGNING OFF
Linux
Install
Only tested on Ubuntu , other distributions need to check the information by themselves (should be similar)
- Run the following command with root privileges
apt install linux-tools-`uname -r` linux-cloud-tools-`uname -r` linux-tools-common # 下面两个不确定要不要安装,但是我都装了 apt install linux-tools-generic linux-cloud-tools-generic
configuration
- Load the relevant kernel modules:
- Not sure if you need to reload after restarting the computer
sudo modprobe usbip-core sudo modprobe vhci-hcd sudo modprobe usbip_host
- Turn off the firewall:
ufw disable
- Or open a TCP connection on port 3240 in the firewall
The following operations are very similar to root windows, see the configuration process of windows above for details & pictures
- Connect the USB device to the computer, then use the command
usbip list -l
to list all recognized USB devices - Find the USB device you want to share remotely, and record its busid in the format
[数字]-[数字]
- Bind the USB device to usbip
usbip bind -b [busid] # 例如 usbip bind -b 1-181
- Start the usbipd service
usbipd -d -4 # 如果想用其他端口,且安装的时候配置过防火墙 usbipd -d -4 -tPORT [端口]
- After use, you can unbind the USB device with usbip
usbip unbind -b [busid]
Client (computer B)
Windows
PS : You can also see the official README for installation and configuration methods
The installation method is almost the same as the server side above, but there is one more step
- Install the VHCI driver: Open CMD or PowerShell as an administrator , enter the directory where the software is located, and run the following command
If you don't need it later, you can uninstall the driverusbip.exe install
usbip.exe ubinstall
configuration
-
Open CMD or PowerShell as an administrator and enter the directory where the software is located
-
View available USB devices on computer A
usbip.exe list --remote [电脑A的IP]
-
Bind the USB device to the machine
usbip.exe attach --remote=[电脑A的IP] --busid=[想要绑定设备的busid]
-
View the bound remote USB devices
usbip.exe port
-
Unbind the bound remote USB device: the port comes from
usbip port
the number after "Port" in the command outputusbip.exe detach -p [端口]
Linux
The installation method is the same as that of the server side
configuration
-
View available USB devices on computer A
usbip list --remote [电脑A的IP]
-
Bind the USB device to the machine
usbip attach --remote=[电脑A的IP] --busid=[想要绑定设备的busid]
-
Check the local USB device, you should be able to see the bound USB device
lsusb
For example
-
View the bound remote USB devices
usbip port
-
Unbind the bound remote USB device: the port comes from
usbip port
the number after "Port" in the command outputusbip detach -p [端口]
Refer to connect to
Linux system and use USB/IP to remotely share USB devices
USB/IP PROJECT
Linux usb 5. usbip (USB Over IP) usage example
USB/IP for Windows