Connecting to Your Android Termux Instance via ADB and SSH

Requirements

Setting Up OpenSSH in Termux

  1. Install OpenSSH:

    pkg install openssh
  2. Start the SSH daemon:

    sshd

Connecting the Devices via Wire or Local Network

In Termux

  1. Set a password for your SSH connection:

    passwd

On Your PC

  1. Check connected devices:

    adb devices
  2. Forward the ADB connection:

    adb forward tcp:8022 tcp:8022

    Output should indicate the forwarding, e.g., >>> 8022.

  3. Accept the ADB connection on your phone when prompted.

Final Connection

  1. Again, on your PC, establish the SSH connection:

    ssh localhost -p 8022
  2. Enter the password you set earlier when prompted.

Now you should be connected to your Android Termux instance!