Termux is a full-feeling terminal on Android with a package manager that keeps growing. It is a small Linux environment in your pocket.

Below is how I put an SSH server on it and reached it from another machine on the LAN.

$ means a command in Termux. # means a command on the remote client.

Installing packages

Update packages first:

$ pkg upgrade

Install OpenSSH:

$ pkg install openssh

Starting and stopping the SSH server

Start it:

$ sshd

Stop it by killing the process:

$ pkill sshd

Password authentication

Key auth is safer. For a short local setup I used a password and accepted the tradeoff.

Password auth is on by default in Termux. You can still inspect the config:

$ cat $PREFIX/etc/ssh/sshd_config

Mine looked like this:

PrintMotd yes
PasswordAuthentication yes
PubkeyAcceptedKeyTypes +ssh-dss
Subsystem sftp /data/data/com.termux/files/usr/libexec/sftp-server

Set a password:

$ passwd

New password:
Retype new password:
New password was successfully set.

After that the phone is ready to accept SSH.

Connecting from another machine

Find the phone’s LAN address:

$ ifconfig

In this run the Wi-Fi address was 192.168.100.92:

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.100.92  netmask 255.255.255.0  broadcast 192.168.100.255
        inet6 fe80::d4d0:8cac:6318:8ac9  prefixlen 64  scopeid 0x20<link>
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 1000  (UNSPEC)
        RX packets 1118178  bytes 1321397645 (1.2 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 577939  bytes 80497172 (76.7 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Connect from the other machine on port 8022:

# ssh anything@192.168.100.92 -p 8022

Termux accepts any username. I used anything here.

Enter the password you set earlier and you should land in a shell.

SSH to Termux from remote machine