Cookie
FlexiHub Team uses cookies to personalize your experience on our website. By continuing to use this site, you agree to our cookie policy. Click here to learn more.

How to Share USB over Ethernet With Raspberry Pi

In many situations, it is very much desirable to have an opportunity of sharing a USB peripheral across the network. For one, if you have a whole team using some pricey licensed software protected with a USB security key. No one wants to spend a fortune on individual licenses for each employee or gamble with losing or damaging said key as it’ll be carried around the office plugged into different machines all day long.

FlexiHub


Windows, macOS, Linux, Android
4.8 Rank based on 78+ users
Share Serial over IP
As you may already know, there is a way to set up your Raspberry Pi as a USB-over-Ethernet server. Well, actually, there is not one, but two roads you can take here: an easy path with the hundred-per-cent efficient paid app or a bumpy ride with an open-source solution and its fiddly config process. And we’re about to take a look at both.

Quick and safe USB sharing from Raspberry Pi with FlexiHub

With the right software tool, sharing USB over IP from a Raspberry Pi is less than simple:
1
Download the Linux version;
2
In your Raspberry’s terminal, run the following command: yum install [package];
3
Start the app and click “Share” next to your device.

That’s it!

From that point on, the shared device will be remotely accessible from any Linux, Windows, or Mac machine with installed FlexiHub and the Internet connection, no matter the physical distance. Thanks to the unique USB Redirection Server, the app truly is an internetwork solution that works through all firewalls and doesn’t require public IP addresses.

FlexiHub

Windows, macOS, Linux, Android
4.8 Rank based on 78+ users
On top of that, FlexiHub has an optional traffic compression feature that is very helpful when it comes to sharing bandwidth-sensitive USB devices like USB cameras, and a bulletproof 2048-bit SSL encryption to completely prevent unwanted access to your security dongles or any data passed with the app.
FlexiHub

And the icing on this cake is that you don’t really need to permanently turn your Raspberry Pi into a USB-over-IP server. You can share USB devices from any machine with installed FlexiHub, including your Android tablet, and never have any trouble with cross-platform connectivity. From a Windows machine, you can even share a COM-based peripheral. How awesome is that? And, for added convenience, you’ll get an opportunity to enjoy wireless connectivity accessing shared devices via Wi-Fi.

A Free Way to Setup a Raspberry Pi as a USB-over-IP server

In principle, this method is similar to the one we've just described, but through the agency of a different app. And given that this time we’ll be using an open-source solution that's still in development, the set-up process requires a decent level of technical competence to perform so if you don’t have any, don't be surprised if it won’t work on the first go.

Here are some more important points you need to consider before opting for this method:

  • Only works for sharing USB devices in your local network.
  • Can’t share a device from a non-Linux machine.
  • The more the distance to the shared device — the worse the connection.
  • No protection for unauthorized access.
  • No traffic compression, so an image from a remote camera may lag a lot.

Let’s start with setting up your Raspberry Pi as a server:

1
Install the app using this command: sudo apt install usbip
2
Once the installation is complete, add the kernel module we’ll need by entering:
sudo modprobe usbip_host
echo 'usbip_host' >> /etc/modules
3
Now, use the lsusb command to view a list of all USB devices physically connected to your Raspberry Pi and remember (or write down) the 8-digit USB ID number of a device you’re going to share.
4
Use the usbip list -p -l command to find out your device’s bus ID (use the USB ID number from a previous step to identify the right device on the list). Write down that number.
5
Run the command:
sudo usbip bind --busid=N
(N is the bus ID number from the previous step)
6
Run the demon to attach the device to the USB/IP by executing the command: usbipd

Alternatively, you can create a systemd service:

vi /lib/systemd/system/usbipd.service

with the following definition (don’t forget to change the N for an actual USB ID number of your device):

  [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



And then you'll need to run these commands to start that service:

sudo systemctl --system daemon-reload
sudo systemctl enable usbipd.service
sudo systemctl start usbipd.service

Ok, now let's set up a client:

Note: The app does have a client for Windows, but it’s a flimsy beta version with no signed drivers or any support for Windows 10, thus not really worth mentioning.

1. To install the same app for sharing USB over IP in Ubuntu, execute these commands:
sudo -s
apt-get install linux-tools-generic -y

2. Enable the required module:
modprobe vhci-hcd
echo 'vhci-hcd' >> /etc/modules

Now, to connect the shared device to this machine, run the command: sudo usbip attach -r 0.0.0.0
(type the actual IP address of your Raspberry Pi instead of 0.0.0.0)

Or you can create a systemd service:
vi /lib/systemd/system/usbip.service

With the definition (replace N with an actual USB ID number of your device and 0.0.0.0 with your Raspberry’s IP address):

[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 

Save, and then run these commands to start the service:

sudo systemctl --system daemon-reload
sudo systemctl enable usbip.service
sudo systemctl start usbip.service

After that, you should be able to access the shared device remotely. If not, try all the steps again from the very beginning.

Important! If you unplug a USB device from the Raspberry Pi while it’s shared by this method it may result in permanent data loss. Turn off your Raspberry first.

USB sharing with FlexiHub
30-day demo period

A table for comparison between the two methods:

Proxi-server
Proxi-server
Redirection Server
• no need for external IP
• multi-network communication
• works through the Firewall
 
N/A
 
Supported platforms:
Supported platforms:
 
 
Server-side
Server-side
✓ Windows
✓ Linux
✓ macOS
✓ Android
 
✓ Linux
 
Client-side
Client-side
✓ Windows
✓ Linux
✓ macOS
 
✓ Windows (beta)
✓ Linux
 
Firmware for microcontrollers
Firmware for microcontrollers
Raspberry (upon request)
 
N/A
 
Security
Security
Login tokens for safe account sharing
Lock for device access control
 
N/A
 
Encryption
Encryption
2048-bit SSL
 
N/A
 
Enhanced stability
Enhanced stability
Keep connection active option
 
N/A
 

Closing remarks

For sure, it's totally up to you to decide which one of the two methods described in this article you’re going to take on board. But wouldn't it be better to invest in an easy-to-handle tool with proven efficiency than rely on something that can fail at any time and cause you who knows how much nerves, time, and money due to unplanned downtime.


Top choice

FlexiHub

  • Rank 4.8 based on 78+ users
  • Windows 7/8/10, Server 2008 R2/2012/2016/2019. 6.99MB Size.
  • Version 4.5.13261. (9 Mar, 2021).