Setting up SSH on Termux
Entering commands with the Android touch screen can be a pain. You can either connect a keyboard or setup SSH to remotely connect from a computer instead. This also allows you transfer files to your device using a SFTP client.
To enabled SSH on your Android device:
- Open Termux and
installmake sure your packages are up to date:pkg update
- Install SSHD:
pkg install openssh
- Set a password:
passwd
- Get your username:
whoami
- Get your ip address:
ifconfig
OnamostRP3,wifi devices, it should be the inet value underwlan0wlan0. - Start sshd:
sshd
If you get a "no hostkeys available" error, runssh-keygen -A
and then trysshd
again.
On your computer use a ssh client to connect.connect on port 8022. Windows 11, Linux, and Mac computers should be able to use the ssh command in commandline:their terminal/command line: ssh username@ipaddress -p 8022
. Windows 10 and below maybemay need to install an SSH client such as PuTTY or Windows Terminal.
SSHD will remain running in Termux so long as the app remains running, even in the background. You'll see it in the Android notification area if it's running (with the >_ icon). If the app closes completely, you will need to re-run sshd to start it again.