Android adb

From Ever changing code

Ssh to Termux over usb

On Android device (tested with Android 10)

  • Settings > Additional setings > Enable developer debug mode
  • Open Termux and set up sshd
apt install openssh   # install the OpenSSH package 
sshd                  # start the ssh server
killall sshd; sshd -d # troubkeshoot in debug mode
ssh localhost -p 8022 # verify, You can't do password authentication in Termux

# Add public key
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh
echo "open-ssh aaabbbcc"
  • Connect the device using USB

On Linux machine install adb

sudo apt install adb

# Create your port forward,
# The first instance of tcp:8022 is the local port you want to bind the remote port to. The second one is the port from your Android device. Because Termux' SSHD runs on port 8022 by default,
adb forward tcp:8022 tcp:8022
ssh localhost -p 8022 # only key connections are accepted, thus connecting here with id_rsa key

Welcome to Termux!

Community forum:
Gitter chat:
IRC channel:     #termux on freenode

Working with packages:

 * Search packages:   pkg search <query>
 * Install a package: pkg install <package>
 * Upgrade packages:  pkg upgrade

Subscribing to additional repositories:

 * Root:     pkg install root-repo
 * Unstable: pkg install unstable-repo
 * X11:      pkg install x11-repo