A laptop running Android Studio and a linux server somewhere (office, basement, other side of the world) with connected Android devices. (No Android device connected on local laptop). Normally, you would have to unplug the device from the server, plug it into the laptop, continue development.
Now you can skip this.
(From now on, local is the laptop. The machine which doesn't have anything connected. remote is the machine which has the adb devices but doesn't have anything useful to do with them)
It can work both for Windows WSL and Linux local.
Install it as you would normally do in Linux, aka inside ~/bin
for example, so you end up with a adb
PATH like this:
$ which adb
/home/kreach3r/bin/android/sdk/platform-tools/adb
or other equivalent programs installed.
With whatever method you can find, I choose to place it inside ~/.bashrc
.
Same procedure as before. End up with same path. Place into PATH.
I only tested this with ConEmu. Open a {Bash::bash}
terminal window. In Linux, choose whatever you want.
The path should be ~/.ssh/config
. Make sure you have a working SSH connection with the host SERVER before proceeding.
Example:
Host SERVER
Hostname www.server.com
User kreach3r
IdentityFile ~/.ssh/id_private
Port 22
LocalForward 5037 localhost:5037
This is optional, but it saves you having to do it manually each time.
# Always start adb server after login
adb start-server &> /dev/null
ADB server should start.
Same devices should appear! Profit!
Again, this is optional, but saves you having to open another terminal window to ssh SERVER
to keep to start/keep the connection alive.
sudo apt install autossh
Place this into your local ~/.bashrc
:
# Run autossh daemon for local forward porting without needing to login manually to ssh
autossh -M 20000 -f -N SERVER
http://www.tinmith.net/wayne/blog/2015/11/android-remote-adb.htm
https://stackoverflow.com/a/27879297
https://stackoverflow.com/a/9532938
https://stackoverflow.com/a/9146502
https://unix.stackexchange.com/a/134545
https://serverfault.com/a/598276/404661