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
- Find your Android IP: Use a separate app or command like
ip addr(if installed) orifconfig(if installed viapkg install net-tools). - 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.)