DEV Community

Cover image for Remote Access to Termux via SSH: Managing Your Smartphone from a PC
Den
Den

Posted on

Remote Access to Termux via SSH: Managing Your Smartphone from a PC

Managing files, running scripts, and executing terminal commands on your smartphone from a computer is much more convenient through a full SSH session, eliminating the need to switch between device screens.
​Installing OpenSSH
Open Termux and install the package for the secure protocol:

pkg update && pkg install openssh
Enter fullscreen mode Exit fullscreen mode

Configuration
​Set a password to secure the connection: passwd

  • Find your current username using the whoami command (usually looks like u0_a...).
    ​Start the SSH server: sshd
    ​Connecting from a PC
    Find your smartphone's local IP address using ifconfig(look for the inet line under the wlan0 interface).

  • Note that Termux uses a non-standard port 8022 by default instead of the standard 22.

  • Connect from your computer (Linux, macOS, or Windows via PowerShell/PuTTY):

ssh <username>@<smartphone_IP> -p 8022
Enter fullscreen mode Exit fullscreen mode

After entering your password, you will gain full access to your phone's terminal directly from your PC.
Autostarting the Server
To avoid starting the server manually every time you open the app, add the command to your shell configuration:

echo "sshd" >> ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

This tool turns your mobile device into a fully functional remote node that is easy to manage over the local network when developing and testing lightweight projects.

I share more simple and awesome smartphone IT projects on my Telegram channel: @termuxq

Top comments (0)