This guide outlines the steps to set up an SSH server and Tailscale on a fresh Debian installation inside the Android Linux Terminal App. After completing these steps, you'll be able to securely SSH into the Linux environment running on your Android device from any remote machine over the internet using Tailscale.
-
Update package lists and upgrade installed packages to the latest versions:
sudo apt update && sudo apt upgrade -y
-
Install OpenSSH server to enable SSH access and neofetch to print system info:
sudo apt install -y openssh-server neofetch
-
Configure the SSH server to use port 8022 (edit SSH config file):
Currently, the Android Linux Terminal App does not support port forwarding to the device's public address (only forwards to localhost). However, here we change the port in case support is added in the future and show Port Forwarding is working in Terminal App Settings:
sudo sed -i 's/#Port 22/Port 8022/' /etc/ssh/sshd_config
-
Restart the SSH service to apply changes:
sudo systemctl restart ssh
-
Set a password for the
droid
user:sudo passwd droid
-
Install Tailscale to create a software-defined network (SDN) to allow SSH access from other devices on the same network:
Since port forwarding does not work to the device’s public address (only localhost), Tailscale (or another SDN tool like ZeroTier) can help you create a virtual network:
curl -fsSL https://tailscale.com/install.sh | sh
-
Authenticate and connect to Tailscale:
You will need a Tailscale account already created. Log in to Tailscale via the browser using the URL provided:
sudo tailscale up
-
Note that both SSH and Tailscale services are enabled to start automatically on boot (aka when the Linux Terminal App is started):
sudo systemctl is-enabled ssh sudo systemctl is-enabled tailscaled
-
Print and save the Tailscale IP Address:
Record the IP address provided by Tailscale (e.g.,
100.107.7.76
):tailscale ip
-
From the remote machine you wish to SSH from:
Ensure Tailscale is set up and connected on the remote machine. Then, connect via SSH using the IP address recorded above:
ssh [email protected] -p 8022 droid@localhost:~$ neofetch _,met$$$$$gg. droid@localhost ,g$$$$$$$$$$$$$$$P. --------------- ,g$$P" """Y$$.". OS: Debian GNU/Linux 12 (bookworm) aarch64 ,$$P' `$$$. Host: Unknown Product ',$$P ,ggs. `$$b: Kernel: 6.1.0-32-arm64 `d$$' ,$P"' . $$$ Uptime: 1 hour, 21 mins $$P d$' , $$P Packages: 503 (dpkg) $$: $$. - ,d$$' Shell: bash 5.2.15 $$; Y$b._ _,d$P' Terminal: /dev/pts/1 Y$$. `.`"Y$$$$P"' CPU: (8) `$$b "-.__ Memory: 410MiB / 3926MiB `Y$$ `Y$$. `$$b. `Y$$b. `"Y$b._ `"""
That's clever! thank you