Share adb device with another computer

1 minute read

Android adb device was attached to laptop(C1) running Ubuntu, the other computer also with Ubuntu installed, we call it C2.

SSH Tunneling

Both computer should install the same version of adb:

wget -c https://dl.google.com/android/repository/platform-tools-latest-linux.zip
cp -frp platform-tools/ ~/.local
export PATH=$HOME/.local/platform-tools:$PATH

C1:

adb devices
List of devices attached
0ab1d3fa7d25	device

ssh -XC -R 5037:localhost:5037 192.168.1.62

C2:

adb kill-server

adb devices
List of devices attached
0ab1d3fa7d25	device

usbip

Install usbip on both computers:

sudo apt install -y linux-tools-$(uname -r) hwdata

C1:

List available devices:

usbip list -l
[...]
 - busid 3-3 (2717:ff08)
   Xiaomi Inc. : Redmi Note 3 (ADB Interface) (2717:ff08)

Bind usb device:

sudo modprobe usbip_host
sudo usbip bind -b 3-3

Start usbip daemon:

sudo usbipd&

C2:

List remote usb devices

sudo usbip list -r 192.168.1.78
Exportable USB devices
======================
[...]
 - 192.168.1.78
        3-3: Xiaomi Inc. : Redmi Note 3 (ADB Interface) (2717:ff08)
           : /sys/devices/pci0000:00/0000:00:14.0/usb3/3-3
           : (Defined at Interface level) (00/00/00)

Attach adb device:

sudo modprobe vhci-hcd
sudo usbip attach -r 192.168.1.78 -b 3-3

Check attached adb device:

sudo usbip port
Imported USB devices
====================
Port 00: <Port in Use> at High Speed(480Mbps)
       Xiaomi Inc. : Redmi Note 3 (ADB Interface) (2717:ff08)
       3-1 -> usbip://192.168.1.78:3240/3-3
           -> remote bus/dev 003/049
adb devices
List of devices attached
0ab1d3fa7d25	unauthorized