Termux: A Pocket Network Toolkit for When You're Away From the Lab

Most of this blog is written from a desk with a rack nearby. This one is written from the road, on a phone, which turns out to be a fair test of whether a toolkit is any good.

Termux is a terminal emulator and Linux userland for Android. It needs no root, and it gives you a real package manager, a real shell and a real SSH client. For a network engineer that is enough to do a surprising amount of useful work: check a service, reach back into a lab, run a quick scan from a different vantage point, or fix something from a car park.

This post covers the setup I use, the recipes I actually reach for, and the handful of things an unrooted phone cannot do.

Install it from the right place

Install Termux from F-Droid or from the project’s GitHub releases, not the Play Store. The Play Store build is no longer maintained, and its package repositories have gone stale, which shows up as confusing install errors later. If you add the Termux:API companion app, install it from the same source, because mixing sources breaks the signature match between the two.

The starter kit

Update first, then install the tools in one go:

pkg update && pkg upgrade -y
pkg install -y openssh nmap dnsutils whois traceroute iperf3 curl jq python tmux netcat-openbsd socat mosh

That gives you SSH and mosh, scanning, DNS lookups, path tracing, throughput testing, an HTTP client, JSON parsing, Python, a terminal multiplexer, and the two small networking Swiss Army knives.

One habit worth building straight away is keeping the phone awake during long sessions:

termux-wake-lock

Without it, Android will happily suspend your session when the screen goes off, and you will wonder why a long-running job died.

SSH keys and a config file

A phone is easy to lose, so treat its key as disposable. Generate a dedicated key for the phone and put only that public key on the hosts you want to reach, so you can revoke it without touching anything else:

ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_phone -C "anon-phone"

Then a small config so you are typing short names rather than long commands:

cat >> ~/.ssh/config << 'EOF'
Host jumpbox
    HostName 192.0.2.10
    User anon
    IdentityFile ~/.ssh/id_ed25519_phone
    ServerAliveInterval 30

Host lab-fw
    HostName 10.0.0.1
    User admin
    ProxyJump jumpbox
EOF
chmod 600 ~/.ssh/config

The addresses are documentation examples, so swap in your own. The ProxyJump line is the important part: ssh lab-fw now hops through the jump host without any extra thought, which is exactly what you want when typing with thumbs.

On flaky mobile data, mosh is worth a try. It survives the phone switching between Wi-Fi and cellular, which plain SSH does not.

Recipes I actually use

Is the service up, and how slow is it? Curl can time every phase of a request:

curl -o /dev/null -s -w 'dns %{time_namelookup}s  connect %{time_connect}s  tls %{time_appconnect}s  total %{time_total}s\n' https://michealgarner.co.uk

Quick DNS checks against a specific resolver, which is useful for spotting split-horizon surprises:

dig +short michealgarner.co.uk @1.1.1.1
dig +short michealgarner.co.uk @8.8.8.8

What is actually listening from the outside? Run this from the phone on cellular data and you get a genuine outside view of your own public address, with no VPN in the way:

nmap -sT -Pn -p 22,80,443 michealgarner.co.uk

Reach a web interface that only listens inside the lab, by forwarding a local port over SSH and then browsing to it on the phone:

ssh -L 8443:10.0.0.1:443 jumpbox

Leave that session running, then open https://localhost:8443 in the phone’s browser.

How good is this link, really? An iperf3 client against a server you control gives you a proper number rather than a speed-test app’s opinion:

iperf3 -c 192.0.2.10 -t 10

What an unrooted phone cannot do

Android does not give an ordinary app raw socket access, and that shapes what works:

  • No SYN scans. nmap -sS needs raw sockets, so use -sT (a full TCP connect scan) as above. It is slower and noisier in logs, but it works.
  • No packet capture. tcpdump needs root. If you need captures, capture on the far end and look at the result on the phone.
  • Some ICMP tooling is limited. Test your preferred path-tracing tool before you depend on it. traceroute works in many setups; treat anything else as something to verify rather than assume.

None of these are a reason to avoid the setup. They are the line between “useful toolkit” and “pretend laptop”, and knowing where that line sits is the whole point.

Keeping it tidy

Two small things make the phone version far more pleasant than it has any right to be:

  • Run everything inside tmux, so a dropped connection or an accidental swipe does not kill your work.
  • Use a hardware keyboard if you have one. Typing | and ~ on a touch keyboard builds character.

The verdict

Termux will not replace a laptop, and it does not try to. What it does is remove the “I can’t check that until I’m back” excuse for a large class of quick jobs. A key, a config file and a dozen packages turn a phone into something that can reach the lab, test an edge from the outside, and prove a DNS answer. For the weight in your pocket, that is hard to argue with.

If you are already a Termux user, I would be interested to hear what is in your package list.