Coding Agents on the Go: Termux, Mosh & ZeroTier
I wanted to kick off a coding agent on my laptop, then leave the house and keep an eye on it from my phone: approve a step, read a diff, redirect it, from the train, the cafe, wherever. The phone doesn’t run the agent. It’s a window onto the laptop that does.
The stack: Termux on Android, ZeroTier for the network layer, ssh key only auth, mosh for session survival, tmux so the agent keeps running, and pi as the coding agent.
ZeroTier
Creates a virtual LAN between your devices over any network: no port forwarding, no public IP needed.
Install on laptop and Android, join the same network. On the laptop:
sudo zerotier-cli join <NETWORK_ID>Authorize both devices in ZeroTier Central and pin their IPs as managed so they don’t drift. Enable the service:
sudo systemctl enable --now zerotier-oneSSH Both Ways
Start with the laptop. Key only, no root login. Temporarily enable password auth for the key copy step:
sudo ssh-keygen -A
sudo tee /etc/ssh/sshd_config.d/10-hardening.conf >/dev/null <<'EOF'
PasswordAuthentication yes
PermitRootLogin no
PubkeyAuthentication yes
EOF
sudo sshd -t && sudo systemctl enable --now sshdOpen the firewall:
sudo ufw allow 22/tcp
sudo ufw allow 60000:61000/udp
sudo ufw enableOn the phone, install Termux from F-Droid, then:
pkg update && pkg upgrade
termux-setup-storage
pkg install openssh
whoami
sshd -p 8022Termux ships with password auth on by default, so the laptop can connect right away. Typing on a phone keyboard is slow, so do the rest from the laptop:
ssh -p 8022 PHONE_USER@PHONE_ZT_IPInside the ssh session, generate a key and copy it to the laptop:
ssh-keygen -t ed25519
ssh-copy-id fabian@LAPTOP_ZT_IPDisable password auth on the phone:
sudo sed -i 's/^PasswordAuthentication yes/PasswordAuthentication no/' $PREFIX/etc/ssh/sshd_config
pkill sshd && sshd -p 8022Mosh & Tmux
Mosh survives network drops and IP changes. Tmux keeps your session alive after disconnect. Still inside the ssh session, install both:
pkg install mosh tmuxAdd to ~/.tmux.conf on the phone:
set -g extended-keys on
set -g extended-keys-format csi-u
Restart tmux:
tmux kill-serverThis makes tmux forward modified keys (Shift+Enter, Ctrl+Enter) properly. Requires tmux 3.5+.
Install Pi
Still inside the ssh session:
pkg install nodejs termux-api git
npm install -g --ignore-scripts @earendil-works/pi-coding-agent
mkdir -p ~/.pi/agent
piExit the ssh session. Back on the laptop, lock it down:
sudo sed -i 's/^PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config.d/10-hardening.conf
sudo sshd -t && sudo systemctl reload sshdOn the phone, test mosh:
mosh fabian@LAPTOP_ZT_IPWorkflow
~/.ssh/config on each side turns everything into one word:
Laptop:
Host phone
HostName PHONE_ZT_IP
User PHONE_USER
Port 8022
IdentityFile ~/.ssh/id_rsa
Phone:
Host laptop
HostName LAPTOP_ZT_IP
User fabian
IdentityFile ~/.ssh/id_ed25519
# phone to laptop
mosh laptop
# laptop to phone
mosh phoneThe agent lives in tmux on the laptop, not the SSH session. From the phone: mosh laptop, then attach. Approve a step, read a diff, redirect, then detach (Ctrl-b d) and pocket the phone. The agent keeps going, and mosh means I can do this from the train without caring when the connection drops.