Back to course

Setting up SSH Server (Termux as an SSH Daemon)

Termux Masterclass: From Zero to Linux Power User on Android

37. Setting up SSH Server (Termux as an SSH Daemon)

If you want to access your Termux environment from a desktop computer (e.g., to transfer files easily or type commands on a full keyboard), you can run Termux as an SSH server (daemon, sshd).

1. Installation and Configuration

Termux's SSH daemon package is called openssh.

bash $ pkg install openssh

Important: Termux does not use standard Linux user accounts. By default, the sshd listens on port 8022 and uses the Termux login password (which must be set manually).

2. Setting the Termux Login Password

This is the password required to log in via SSH (and locally, if configured):

bash $ passwd

Type and confirm a new strong password.

3. Starting the SSH Daemon

bash $ sshd

The daemon starts in the background.

4. Connecting from a Remote PC

  1. Find your Android IP: Use a separate app or command like ip addr (if installed) or ifconfig (if installed via pkg install net-tools).
  2. Connect: From your desktop terminal, connect using the specific port 8022.

bash

Replace [Android IP] with your device's local IP address

$ ssh u0_aXXX@[Android IP] -p 8022

(Remember that the username is your Termux user ID, found via whoami.)