Android adb

From Ever changing code
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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 acme@example.com"
  • 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!

Wiki:            https://wiki.termux.com
Community forum: https://termux.com/community
Gitter chat:     https://gitter.im/termux/termux
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

Resources