
Hey there, somehow you required to connect your Android device to computer or server that not in your local network.
To do so you will learn how to connect your Android device with using Termux App and SSH (Secure Shell).
Related articles
- Android – Open Source Operating System
- Termux Terminal Emulator In Android
- Android Debug Bridge (ADB)
- Secure Shell (SSH)
Installation
First install Termux app from official F-Droid.
Now open Termux app run following commands on terminal
pkg update
pkg upgrade
pkg install openssh android-tools
# Extra Packages
pkg install git python wget
adb start-server
# Check
adb devices
List of devices attached
emulator-xxxx ddevice
Now on your remote server or computer with sudo access.
sudo apt update && upgrade
sudo apt install ssh ufw
sudo ufw allow 22
sudo ufw enable
sudo ufw restart
sudo systemctl enable ssh
sudo systemctl start ssh
To check your remote server/computer IP Address use command ifconfig
ifconfig
inet x.x.x.x
Now on your Termux connect to remote server with SSH
ssh -R 5037:localhost:5037 -N -f user@x.x.x.x
# For Example
ssh -R 5037:localhost:5037 -N -f root@192.168.9.5
Now on Remote Server
adb start-server
adb devices
# Output
List of devices attached
emulator-xxxx device
Now you can run all ADB Shell command from your remote computer to your Android device
To close connection simply kill Termux and stop ssh on server
sudo systemctl stop ssh
That’s it.
Usage
- To remote debugging with Android Studio
- To access your Android device from remote pc