0

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)
7
  • Sorry but this is exactly the same question. It doesn't matter if you want to connect to an ad device or list all devices, the set-up is identical. You should better use the default ports and kill adb server on the cloud server so the adb client can connect to adb server in the laptop.
    – Robert
    Sep 18, 2023 at 17:55
  • @Robert then can you answer why it is possible to list the device on the laptop, but not on the cloud server and how to connect the cloud server so that it sees the Android device?
    – ecokjeonb
    Sep 18, 2023 at 17:56
  • I'm following the steps at github.com/Genymobile/scrcpy/blob/master/doc/tunnels.md since I want to be able to use scrcpy later too.
    – ecokjeonb
    Sep 18, 2023 at 17:58
  • @MorrisonChang yes, I did 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).
    – ecokjeonb
    Sep 19, 2023 at 0:26

0

You must log in to answer this question.

Browse other questions tagged .