Being able to share a USB device across the network can be very beneficial in lots of day-to-day situations. Say, you have a license dongle for the software everyone in your office needs to use. And every single day that dongle gets plugged in and pulled out more times than anyone can count and chances are good that at some point it will just fall into pieces. Sure, things can’t go on like this forever, but purchasing everyone their own license is way out of your budget. There must be another way around this, right?
Well, as you may have heard, you can share a device connected to USB over TCP/IP with a Raspberry Pi. To do that, you’ll get some special-purpose software. And the main question here is: which one should you get? A surefire paid app or a free, but glitchy open-source solution? Let’s take a look at both.
dpkg -i [package]
apt-get install -f
rpm -i [package]
yum install [package]
That’s it!
After that, you’ll be able to access the shared device from any machine connected to the Internet, no matter the OS on that remote machine (works for Linux, Windows, and Mac), or the physical distance to it. You won’t even need to load the kernel module to launch USB Network Gate on a Linux machine. Plus, the app can be used on VMware, VMware ESX Server, Citrix XenServer, and Microsoft Hyper-V virtual machines. This method works for USB devices of all types and brands. All the device sharing/unsharing takes effect immediately with no system reboot required.
All the connections established with USB Network Gate are totally secure thanks to the advanced 2048-bit SSL encryption. Plus, you can set an authorization password for extra protection. So there’s absolutely no chance any of your data will get into the wrong hands.
The best thing about opting for USB Network Gate is that you don’t really need to permanently turn your Raspberry Pi into a USB-over-IP server. It’s a multi-platform solution great for sharing USB devices from any machine you have, plus, there is no limit as to the number of shared devices.
This method is, at its core, the same way of sharing USB over IP in Ubuntu, only this time we’re going to use a different app. Keep in mind that it’s open-source Linux-based software that is still under development. Make sure you're ready for a technically challenging set-up process and don’t get down if you’ll boggle the first attempt.
Other important points to take note of before we start:
sudo apt install usbip
sudo modprobe usbip_host
echo 'usbip_host' >> /etc/modules
lsusb
usbip list -p -l
sudo usbip bind --busid=N
usbipd
vi /lib/systemd/system/usbipd.service
[Unit]
Description=usbip host daemon
After=network.target
[Service]
Type=forking
ExecStart=/usr/sbin/usbipd -D
ExecStartPost=/bin/sh -c "/usr/sbin/usbip bind --$(/usr/sbin/usbip list -p -l | grep '#usbid=N#' | cut '-d#' -f1)"
ExecStop=/bin/sh -c "/usr/sbin/usbip unbind --$(/usr/sbin/usbip list -p -l | grep '#usbid=N#' | cut '-d#' -f1); killall usbipd"
[Install]
WantedBy=multi-user.target
sudo systemctl --system daemon-reload
sudo systemctl enable usbipd.service
sudo systemctl start usbipd.service
Note: The app’s client version for Windows is a beta with no support for Windows 10. so we won’t consider it here.
sudo -s
apt-get install linux-tools-generic -y
modprobe vhci-hcd
echo 'vhci-hcd' >> /etc/modules
sudo usbip attach -r 0.0.0.0
Or create a systemd service:
vi /lib/systemd/system/usbip.service
defined as:
[Unit]
Description=usbip client
After=network.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/sh -c "/usr/lib/linux-tools/$(uname -r)/usbip attach -r 0.0.0.0 -b $(/usr/lib/linux-tools/$(uname -r)/usbip list -r 0.0.0.0 | grep 'N' | cut -d: -f1)"
ExecStop=/bin/sh -c "/usr/lib/linux-tools/$(uname -r)/usbip detach --port=$(/usr/lib/linux-tools/$(uname -r)/usbip port | grep '<Port in Use>' | sed -E 's/^Port ([0-9][0-9]).*/\1/')"
[Install]
WantedBy=multi-user.target
Don’t forget to replace N with an actual USB ID number of your device and 0.0.0.0 with your Raspberry’s IP address.
Save the service and execute these commands to start it:
sudo systemctl --system daemon-reload
sudo systemctl enable usbip.service
sudo systemctl start usbip.service
If you still can’t access the shared device from the client machine, start again from step 1 of the server set-up guide.
Important! DO NOT unplug USB devices from the Raspberry Pi while it’s shared by this method. Turn off your Raspberry first to prevent data loss and/or save device from being damaged.
Distance limitation
|
Distance limitation
|
None
|
LAN coverage area.
|
Supported platforms:
|
Supported platforms:
|
|
|
Server-side
|
Server-side
|
✓ Windows
✓ Linux
✓ macOS
✓ Android |
✓ Linux |
Client-side
|
Client-side
|
✓ Windows
✓ Linux
✓ macOS |
✓ Windows (beta)
✓ Linux |
Traffic optimization
|
Traffic optimization
|
Optional encryption |
N/A |
Security
|
Security
|
Password |
N/A |
Encryption
|
Encryption
|
2048-bit SSL |
N/A |
Wireless connectivity
|
Wireless connectivity
|
Yes |
N/A |
Activity log
|
Activity log
|
Yes |
N/A |
Whatever method you will go for, please keep in mind that a free option isn’t always the best one. and what seems to be saving at the start can turn out to be a loss later down the road. Nine times out of ten it’s much more rewarding to invest in a tried and tested app that’ll be easy to use and won’t cause any trouble than put your whole operation at stake and batten down the hatches waiting for your free tool’s next failure.