How to Set Up SSH on Termux

termux-ssh-server

🚀 How to Set Up SSH on Termux and Control Your Android Device Remotely

Smartphones are not just for calls and social media anymore — they are powerful pocket-sized computers. With the right tools, you can unlock even more potential. Imagine being able to control your Android phone from your laptop or desktop, run Linux commands remotely, or even transfer files between devices without using a USB cable.

This is exactly what you can do with SSH on Termux. In this guide, we’ll walk step by step through the process of setting up SSH in Termux so you can connect to your Android device remotely. Whether you are a beginner or a tech enthusiast, this tutorial will be simple, detailed, and easy to follow.

✨ What is SSH and Why Use It on Termux?

SSH (Secure Shell) is a protocol that allows secure communication between two devices over a network. Normally, SSH is used to connect to remote servers, but with Termux, you can use it to access your Android device from another computer.

Here’s why SSH on Termux is useful: it allows file transfers between your phone and computer, lets you run remote Linux commands, helps you manage your phone hands-free, and keeps your data secure with encryption. If you’re a developer, sysadmin, or simply curious about Linux, Termux with SSH is a game-changer.

🔧 Step 1: Install Termux and Required Packages

Before setting up SSH, you need Termux installed. It’s not available on the Google Play Store anymore, but you can safely download it from F-Droid. Once Termux is installed, open the app and update everything with:

Next, install the OpenSSH package:

🔑 Step 2: Set a Password for Termux

For security, you must set a password for your Termux user account. Without this, you won’t be able to log in remotely. Type the following command:

You will be prompted to enter a new password. Type it, press enter, and confirm it again. Make sure you use a strong password with a mix of letters, numbers, and symbols.

▶️ Step 3: Start the SSH Server

Now that SSH is installed and secured with a password, let’s start the SSH daemon (server). Run:

By default, Termux runs SSH on port 8022 instead of the standard port 22. If you want to run it in debug mode for troubleshooting, use:

📡 Step 4: Find Your Phone’s IP Address

To connect from another computer, you’ll need your Android device’s local IP address. In Termux, type:

Look for the wlan0 section. Under it, find the inet address, which usually looks something like 192.168.1.15. This is the address you’ll use to connect to your phone over Wi-Fi.

💻 Step 5: Connect from Your Laptop or Desktop

Now comes the exciting part — connecting to your phone from another computer. On Linux, macOS, or Windows with PowerShell or WSL, open a terminal and type:

termux-ssh-server

Replace username with your Termux username, which usually looks like u0_a123, and replace the IP with your phone’s IP address. You’ll be asked for the password you created earlier. Enter it, and you’re connected!

🛠 Troubleshooting SSH on Termux

If you face issues, make sure both devices are connected to the same Wi-Fi network, check that you’re using port 8022 instead of 22, confirm the SSH server is running by typing sshd, and try restarting Termux if the connection fails. On Windows, if PowerShell does not work, you can use PuTTY as an alternative.

🔗 Transferring Files with SCP

One of the best features of SSH is file transfer. You can move files between your computer and phone using the scp command.

For example, to upload a file from your laptop to Termux, run:

To download a file from Termux to your computer:

🔒 Security Best Practices

SSH is secure, but it’s important to follow best practices. Always use strong passwords, avoid using public Wi-Fi when connecting to your phone, and consider changing your password regularly. For extra safety, you can set up SSH key authentication, which allows you to log in without entering a password each time.

🌍 Advanced Tips

Once you’re comfortable with SSH on Termux, you can try advanced features. For example, generate an SSH key on your laptop and copy it to Termux to enable passwordless login. You can also use SSH for remote development, opening a session to code on your phone using editors like Vim or Nano. Another great trick is automating tasks such as backups or updates by running scripts remotely.

📌 Frequently Asked Questions (FAQs)

Q1: Is SSH on Termux safe?
Yes, SSH uses encryption, making it safe. Just make sure to use a strong password or SSH keys.

Q2: Can I connect over mobile data?
By default, SSH works best on the same Wi-Fi network. To connect over mobile data, you would need to set up port forwarding or use a VPN.

Q3: Why does Termux use port 8022 instead of 22?
On Android, port 22 requires root privileges. Termux avoids this by using port 8022.

Q4: Can I use Windows to connect?
Yes, you can use PowerShell, WSL, or PuTTY on Windows to connect to Termux via SSH.

🎉 Final Thoughts

Setting up SSH on Termux turns your Android phone into a mini server you can control remotely. With just a few commands, you can run Linux commands from your computer, transfer files securely, and manage your Android device hands-free.

This setup is perfect for developers, sysadmins, students, and tech enthusiasts who want more power from their devices. Install Termux, configure SSH, and start exploring the full potential of your Android phone today.

Previous Post Next Post