Have you ever wanted to SSH into your Android phone like it's a real Linux server? With Termux, Ubuntu, and Tailscale, you can do exactly that — without root!
This guide walks you through setting up a fully functional Ubuntu environment inside Termux, exposing it via Tailscale, and making it the default shell on your phone. By the end, you'll be able to SSH into your phone from any device in your tailnet.
🧰 Prerequisites
- Android phone
- Tailscale installed and connected on both your phone and your PC
- Termux installed via F-Droid (not from Play Store — it’s deprecated!)
Some Linux experience
⚠️ If You See This Error…
CANNOT LINK EXECUTABLE "-sh": Library "/data/data/com.termux/files/..."
You likely installed Termux from the Play Store, which is broken on modern Android.
Solution: Uninstall Termux and install it via F-Droid or GitHub Releases.
✅ Step 1: Install Ubuntu (or any other distro) in Termux Using proot-distro
pkg update && pkg upgrade
pkg install proot-distro
proot-distro list
proot-distro install ubuntu
To enter Ubuntu:
proot-distro login ubuntu
✅ Step 2: Make Ubuntu the Default Shell in Termux
You want Ubuntu to load automatically when you launch Termux. Here's how:
- Edit the startup script:
nano ~/.bash_profile
- Add this to the end of the file:
if [ -z "$PROOT_DISTRO_NAME" ]; then
proot-distro login ubuntu-22.04
fi
This prevents recursive launches if you’re already inside Ubuntu.
- Reopen Termux Now you'll land directly inside Ubuntu every time you open Termux. 🎉
✅ Step 3: Set Up SSH Server Inside Ubuntu
Launch Ubuntu:
proot-distro login ubuntu
Then run:
apt update && apt install openssh-server
passwd # Set root password
service ssh start
Now your SSH server is live on Ubuntu inside Termux.
✅ Step 4: SSH Into Your Phone via Tailscale
Make sure your phone is connected to Tailscale and visible on your PC. Find the IP (e.g., 101.125.41.99).
From your PC:
If you want to ssh into Ubuntu inside termux
ssh root@ip -p 8022
or you can ssh into termux's shell by first:
Inside termux
whoami # it should be something like u0_a124
Then from your pc or other host device:
ssh u0_a124@ip -p 8022
You can change the port in the sshd_config, or use the default 8022 if inside Termux.
Top comments (0)
Some comments may only be visible to logged-in visitors. Sign in to view all comments.