Skip to content

Instantly share code, notes, and snippets.

@aschober
Created March 19, 2025 04:41
Show Gist options
  • Save aschober/eeb316027c5037fc3af5fb0327ab44fd to your computer and use it in GitHub Desktop.
Save aschober/eeb316027c5037fc3af5fb0327ab44fd to your computer and use it in GitHub Desktop.
Setup SSH and Tailscale on Android 15 Linux Terminal App

Setup SSH and Tailscale on Linux Terminal App

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.

  1. Update package lists and upgrade installed packages to the latest versions:

    sudo apt update && sudo apt upgrade -y
    
  2. Install OpenSSH server to enable SSH access and neofetch to print system info:

    sudo apt install -y openssh-server neofetch
    
  3. 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
    
  4. Restart the SSH service to apply changes:

    sudo systemctl restart ssh
    
  5. Set a password for the droid user:

    sudo passwd droid
    
  6. 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
    
  7. 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
    
  8. 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
    
  9. Print and save the Tailscale IP Address:

    Record the IP address provided by Tailscale (e.g., 100.107.7.76):

    tailscale ip
    
  10. 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._
                  `"""
    
@killsmm
Copy link

killsmm commented Apr 21, 2025

That's clever! thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment