How can I list devices in ADB through SSH, when it works fine locally?
On local, it shows up as device
. and on cloud server, it shows up as offline
.
Setup
┌─────────┐ SSH through internet
│ Physical│ USB cable ┌────────┐ (outside LAN) ┌────────┐
│ Android ├───────────►│ Laptop ├──────────────►│ Cloud │
│ device │ └────────┘ │ server |
└─────────┘ └────────┘
Android device
- enabled USB debugging
- connected to laptop through USB cable
- all "do you trust this device?" prompts have "trust" selected
Laptop
- connected to cloud server with
ssh -L 5038:localhost:5037 -R 27183:localhost:27183 ecokjeonb@redacted
- in first terminal:
> adb -a nodaemon server
- in second terminal:
> adb devices -l
List of devices attached
887d9087 device usb:1-2 product:redacted model:redacted device:redacted transport_id:1
> adb version
Android Debug Bridge version 1.0.41
Version 34.0.4-10411341
Installed as /tmp/platform-tools_r34.0.4-linux/platform-tools/adb
Running on Linux 5.4.0-58-generic (x86_64)
Cloud server
> export ADB_SERVER_SOCKET=tcp:localhost:5038
> export ANDROID_ADB_SERVER_ADDRESS=localhost
> export ANDROID_ADB_SERVER_PORT=5038
> adb devices -l
List of devices attached
localhost:5038 offline transport_id:1
> adb version
Android Debug Bridge version 1.0.41
Version 34.0.4-10411341
Installed as /tmp/platform-tools_r34.0.4-linux/platform-tools/adb
Running on Linux 5.15.0 (x86_64)
scrcpy
later too.adb kill-server
(fresh install, so no running server yet),adb start-server
(adb -a nodaemon server
starts in foreground, not background),ssh -XC -R 5037:localhost:5037
(X forwarding and compression (-XC
) not required) and-L 5038:localhost:5037
(-L
and-R
direction swapped because the "remote" and "local" are swapped. The port is different because I explicitly start it on port 5037 locally, and keep the default of 5038 on the server).