Skip to content

Instantly share code, notes, and snippets.

@donghee
Last active September 21, 2025 03:07
Show Gist options
  • Save donghee/2718e71bcd8c8b223eb66e68b17abcef to your computer and use it in GitHub Desktop.
Save donghee/2718e71bcd8c8b223eb66e68b17abcef to your computer and use it in GitHub Desktop.
USB IP utility; USB device to share is connected to usb server host
#!/bin/sh
sudo apt-get install usbip fzf -y # for debian
sudo apt-get install linux-tools-`uname -r` linux-tools-common fzf -y # for ubuntu
sudo modprobe usbip-core
sudo modprobe vhci-hcd
sudo modprobe usbip_host
usbip --tcp-port 3240 list --remote 127.0.0.1
echo "Enter the bus ID of the USB device to attach (e.g., 3-2.3.2):"
#read BUS_ID
BUS_ID=`usbip --tcp-port 3240 list --remote 127.0.0.1 | fzf --multi | grep -oP '(?<=\b)\d+(?:[-.]\d+)*(?=:)'`
echo "Selected BUS ID: $BUS_ID"
sudo usbip --tcp-port 3240 attach --remote=127.0.0.1 --busid=$BUS_ID
sleep 2
lsusb
#!/bin/bash
sudo apt-get install usbip fzf -y # for debian
sudo apt-get install linux-tools-`uname -r` linux-tools-common fzf -y # for ubuntu
sudo modprobe usbip-core
sudo modprobe vhci-hcd
sudo modprobe usbip_host
usbip list --local
sudo pkill usbipd
sudo usbipd -D --tcp-port 3240
echo "Enter the bus ID of the USB device to share (e.g., 3-2.3.2):"
#read BUS_ID
BUS_ID=`usbip list --local | fzf --multi | grep -oP '(?<=\bbusid\s)\S+'`
echo "Selected BUS ID: $BUS_ID"
sudo usbip bind -b $BUS_ID
echo "Enter the client host (e.g., user@hostname):"
read CLIENT_HOST
ssh -Nf -R 3240:localhost:3240 $CLIENT_HOST
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment