Open the Termux app and update & upgrade packages. Run:
pkg update pkg upgrade
- During upgrade, you may be prompted to replace a version of a packages with the maintainer’s version. Pick the default option (No) for now by just hitting enter.
Install the OpenSSSH package with
pkg install openssh
Set up access for Termux to your to mobile’s storage with
Create a password for the default Termux user with
Get your Termux username with
Start SSH server on your device with the command
Get your mobile’s LAN IP address from your device’s Wi-Fi settings. You can usually get this from the info page of the network you are connected to.
Now from your PC’s command line (Linux, Mac or Windows PowerShell) you can access your mobile with
ssh -p 8022 u02..@192.168.x.x. 8022 is the default port used by Termux. Your PC should be connected to the same Wi-Fi network as your Android.
When you try to connect, you’ll be prompted for a password. Enter your Termux user’s password that you created in Step 4 above.
You’re now logged into your Android and you can use terminal commands to access your device’s files or copy files between your PC and your mobile.
Setting up password-less login
If you already have an SSH key for your PC, you can copy the public key to your mobile to login without a password. To copy your PC’s public key, from your PC:
If you don’t have an SSH key, you can create one on your PC with
ssh-keygen. Run the below command in your PC’s Terminal. In Windows, you can run this in PowerShell.
These steps enable SSH access to your Android over LAN. If you need SSH access to an Android device when it is not connected to your local network, I recommended creating your own private VPN with Tailscale.