You're sitting on the couch, and your Mac is compiling something heavy across the room. You want to check in, maybe run a quick command, maybe just glance at the output. So you grab your phone. Safari? Useless. Slack? Wrong app entirely. You end up walking over to the desk like it's 2009.

That loop ends today.

Three tools, none of them new, solve this problem completely. Blink Shell gives you a real terminal on iOS. Mosh replaces SSH with a connection that refuses to die. And tmux keeps server-side sessions running regardless of what your connection is doing. The three of them turn a phone into a real terminal window to your development machine. WiFi drops, cellular dead zones, your phone sleeping for three hours, none of it kills the session.

The stack has been around for years. Mosh came out of MIT in 2012. tmux is nearly as old as the iPhone itself. But something shifted in the last six months. Developers running AI coding agents from their phones turned this setup from a niche convenience into a daily habit. You kick off a long-running Claude Code session, pocket the phone, and check back when it needs input. The connection holds. The session persists.

The Setup


Three layers of insurance against your network

The three tools form a stack. Each handles a different failure mode.

Start with Blink Shell ($19.99/year on iOS), the client on your phone or iPad. It includes a built-in Mosh client, SSH key management with Secure Enclave support, iCloud sync across devices, and touch gestures designed for small screens. Think of it as your terminal app.

Mosh handles the network layer. SSH uses TCP. Switch from WiFi to cellular and your IP address changes. TCP doesn't recover from that. The connection breaks, the session dies. Mosh uses UDP instead. It runs a protocol called State Synchronization Protocol that synchronizes terminal state between client and server. When your phone's IP changes, the server starts sending to the new address. No reconnection needed. Mosh's creators measured a 50x improvement in average response time compared to SSH on lossy connections.

Then there's tmux, which handles session persistence on the server. Your shell runs inside tmux. If Mosh drops (rare, but it happens after very long idle periods), tmux keeps your processes alive on the remote machine. You reconnect and reattach. Same output, same running processes, same cursor position. As if nothing happened.

The failure modes they cover look like this: Blink gives you the interface. Mosh survives network changes. tmux survives total disconnections. Belt, suspenders, and a backup belt.

Here's where we're headed. Once everything is installed and configured, the entire workflow collapses to a single command from your phone:

mosh mac -- tmux new -A -s work

That connects to your server, attaches to your persistent session (or creates one), and survives anything your network throws at it. The setup below gets you there.

Setting up Mosh on your server/computer

Mosh has to be installed on the machine you connect to. Blink already includes the client side.

macOS (Homebrew):

brew install mosh

Ubuntu/Debian:

sudo apt update && sudo apt install mosh

Fedora:

sudo dnf install mosh

After installation, find the path to the server binary. You'll need this for Blink's configuration.

which mosh-server

On macOS with Apple Silicon, this returns /opt/homebrew/bin/mosh-server. On Intel Macs, /usr/local/bin/mosh-server. On Linux, /usr/bin/mosh-server.

Firewall rules

Mosh needs UDP ports 60000-61000 open. Each concurrent session uses one port.

macOS usually works out of the box on a local network. If you've enabled the firewall in System Settings, add mosh-server as an allowed application. Add the actual binary, not the symlink:

ls -la $(which mosh-server)

Linux (UFW):

sudo ufw allow 60000:61000/udp

Linux (iptables):

sudo iptables -A INPUT -p udp --dport 60000:61000 -j ACCEPT

If you only expect two or three concurrent sessions, open a smaller range. 60000:60010 is plenty.

What Mosh cannot do

Mosh does not support port forwarding, X11 forwarding, SSH agent forwarding, or scrollback. That last one is where tmux comes in.

When Mosh won't work: MCP servers and port forwarding

This is the catch that bites people running local MCP servers. If you have an MCP server listening on localhost:8080 on your dev machine, you'd normally reach it from a remote session by forwarding that port through SSH, something like ssh -L 8080:localhost:8080 mac. Mosh can't do that. It drops all port forwarding because its UDP protocol doesn't support tunnels. So if your workflow depends on reaching local services through SSH tunnels, Mosh is off the table.

The good news: you don't actually need Mosh. Plain SSH plus tmux covers the hard part. tmux keeps your session alive on the server no matter what happens to the connection. If SSH drops, you reconnect and run tmux attach. Nothing was lost.

A few things make the SSH-only path more reliable. Adding ServerAliveInterval 30 and ServerAliveCountMax 3 to your SSH config detects dead connections early instead of letting them hang. autossh goes further, it monitors the tunnel and re-establishes it automatically when it drops. And several mobile SSH clients handle reconnection natively. Blink Shell does it. Termius does it on both iOS and Android. On Android, JuiceSSH and ConnectBot are solid free options.

One more alternative worth knowing about: Eternal Terminal gives you Mosh-style resilience while using SSH's standard port. It supports both tmux and scrollback, which Mosh doesn't. If you need the roaming capability but also need port forwarding, Eternal Terminal threads that needle.

The bottom line: Mosh makes mobile connections better. But tmux is the part that actually matters for session persistence, and it works with any transport.

Setting up tmux on your server

tmux also lives on the server side.

macOS:

brew install tmux

Ubuntu/Debian:

sudo apt update && sudo apt install tmux

Fedora:

sudo dnf install tmux

The concepts you need

tmux organizes things in three levels. Sessions are the top level, like separate desktops. Windows are tabs within a session. Panes are splits within a window. Sessions persist on the server even when no client is attached. That's the whole point.

Configuration

Create ~/.tmux.conf on your server:

# Increase scrollback from the default 2000 lines
set-option -g history-limit 10000

# Mouse support: scroll, select panes, resize with touch
set -g mouse on

# Start numbering at 1 (easier to reach on phone keyboards)
set -g base-index 1
setw -g pane-base-index 1

# Reduce escape delay (snappier over remote connections)
set -sg escape-time 10

# Keep sessions alive when no client is attached
set -g destroy-unattached off

Mouse support matters more than you'd expect on a phone. Being able to tap panes and scroll with your finger changes the experience from painful to usable.

Reload the config without restarting:

tmux source-file ~/.tmux.conf

Commands that matter

You don't need to memorize everything. These eight commands cover 90% of daily use.

From the command line:

tmux new -s work          # Create a named session
tmux ls                   # List sessions
tmux attach -t work       # Attach to a session
tmux new -A -s work       # Attach if exists, create if not
tmux kill-session -t work # Destroy a session

Inside tmux (all start with Ctrl+B, then release, then the key):

Action Keys
Detach from session Ctrl+B then d
New window Ctrl+B then c
Next window Ctrl+B then n
Previous window Ctrl+B then p
Split horizontally Ctrl+B then %
Split vertically Ctrl+B then "
Switch panes Ctrl+B then arrow keys
Enter scroll mode Ctrl+B then [
Show all bindings Ctrl+B then ?

One command deserves special attention: tmux new -A -s work. The -A flag means "attach if this session already exists, otherwise create it." This single command handles both first-time creation and reconnection. Worth memorizing.

You can find Blink Shell on the App Store for $19.99/year. Two-week trial first, and honestly the price is fair for what amounts to a full professional terminal on your phone.

Fair warning: Blink buries its settings. To open them, type config into the terminal and hit Enter. With an external keyboard, Cmd + , also works.

Generate an SSH key

Go to Keys and tap the + icon. Select Generate New. Choose Ed25519. Name it or leave the default id_ed25519. Blink can store keys in the iOS Secure Enclave, which means the private key never leaves the hardware.

Tap the key to copy the public portion. You need to add it to ~/.ssh/authorized_keys on your server. The fastest way, if you have another terminal handy:

# On your server, paste the public key
echo "ssh-ed25519 AAAA... your-key-name" >> ~/.ssh/authorized_keys

Configure a host

Go to Hosts and tap +.

Field Example value Notes
Alias mac What you type to connect
Hostname 192.168.1.50 Your server's IP
User marcus Your username on the server
Port 22 Default SSH port
Key id_ed25519 The key you generated
Mosh Server /opt/homebrew/bin/mosh-server Path from which mosh-server

Leave the Mosh Port and Command fields empty. Mosh auto-negotiates a UDP port, and an empty command opens your default shell.

Touch gestures

Action Gesture
Switch between shells Swipe left/right
Zoom text Pinch
New shell Two-finger tap
Close shell Two-finger swipe down

With an external keyboard, hold Command to see all shortcuts.

Two commands and you're in

Server setup is done. Blink is configured.

First time, on your server:

tmux new -s work

From Blink on your iPhone:

mosh mac
tmux attach -t work

That's it. Two commands. You're now looking at a persistent terminal session from your phone.

What happens when you disconnect

Your iPhone goes to sleep. You switch to Messages. You walk through a dead zone. Mosh notices the connection is idle but holds the session open. tmux doesn't care at all, it keeps running on the server regardless. Minutes or hours later, you come back to Blink. Mosh reconnects automatically over UDP. Your tmux session is exactly where you left it, as if you never closed the app.

If Mosh fully disconnects (rare, but possible after very long idle periods):

mosh mac
tmux attach -t work

Same two commands. Your tmux session never stopped.

The one-liner

For the laziest possible workflow, make this your daily driver:

mosh mac -- tmux new -A -s work

Single command. Mosh connects, then immediately attaches to the work session (or creates it). Open Blink, type this, done.

Same session, two screens

One of tmux's tricks: multiple clients can attach to the same session simultaneously. Your Mac and your iPhone see the same terminal in real time.

On your Mac:

tmux new -s work
# Start working

On your iPhone via Blink:

mosh mac
tmux attach -t work

Both screens update live. You can type from either device. Start something on your Mac, continue from the couch.

Why AI agents made this setup matter

This stack was built for reliability, not AI. But it turns out that reliability is exactly what AI coding agents need. Tools like Claude Code run long tasks that can take minutes. You don't want to stand at your desk watching a progress indicator. You want to fire and forget.

mosh mac
tmux new -A -s claude
claude

Give it a task. Put the phone down. Come back later. The session held. The agent finished (or it's waiting for your input). Either way, nothing broke.

One developer, rogs, took this further by wiring Claude Code's hook system to push notifications via ntfy. When Claude needs input or finishes a task, the phone buzzes. The async loop becomes: assign task, pocket phone, get notification, respond, pocket phone again. Development fits into the gaps of the day.

Skip the second command entirely

The one-liner above and the auto-attach trick below achieve the same goal: getting into tmux with a single command. Pick one, not both, or you'll end up with nested tmux sessions.

You can eliminate the tmux attach step entirely. Add this to your shell config on the server.

For bash/zsh (~/.bashrc or ~/.zshrc):

if [ -n "$SSH_CONNECTION" ] && [ -z "$TMUX" ]; then
    tmux attach -t work 2>/dev/null || tmux new -s work
fi

For fish (~/.config/fish/config.fish):

if set -q SSH_CONNECTION; and not set -q TMUX
    tmux attach -t work 2>/dev/null; or tmux new -s work
end

The SSH_CONNECTION check matters. It prevents tmux from auto-launching when you're physically at the machine. Only remote sessions get the tmux treatment.

Now your workflow shrinks to one command:

mosh mac

Mosh connects. The shell auto-attaches to tmux. Done.

Troubleshooting the three things that will go wrong

"Nothing received from server on UDP port" means the firewall is blocking Mosh's UDP traffic. Go back to the firewall section above and open ports 60000-61000.

"mosh-server: command not found" means the Mosh Server path in Blink's host config is wrong. SSH into the server, run which mosh-server, copy that exact path into Blink's host settings.

tmux session exists but won't attach. Another client is probably still connected. Force it:

tmux attach -dt work

The -d flag detaches other clients before attaching yours.

The low-grade anxiety this kills

Developers know the feeling. You're away from your desk and something is running. A build, a migration, an agent chewing through a refactor. The nervous itch to check. The half-formed worry that the connection dropped, the session died, the output scrolled past and vanished.

This setup kills that anxiety because every failure mode has a backstop. Belt, suspenders, and a backup belt. Mosh handles your flaky connection. tmux handles total disconnections. Blink puts both in your pocket.

And the use case is shifting. When AI agents run tasks that take 20 minutes at a stretch, "check in from your phone" stops being a convenience trick and starts being the default. You don't need to be at your desk for something that needs your attention twice an hour. The phone becomes the primary interface for monitoring, not a fallback.

The tools have been ready for over a decade. The workflows finally caught up.

Frequently Asked Questions

Does Mosh work with SSH tunnels and port forwarding?

No. Mosh uses UDP and drops all port forwarding. If you need to reach local services like MCP servers through SSH tunnels, use plain SSH with tmux instead. autossh or Eternal Terminal can add reconnection resilience without sacrificing tunnel support.

What happens to running processes if my phone dies completely?

Nothing. tmux runs on the server, not your phone. Your processes continue regardless of what happens to the client connection. Reconnect with mosh mac and tmux attach -t work to pick up exactly where you left off.

Is Blink Shell the only iOS terminal that supports Mosh?

Blink is the most full-featured option with built-in Mosh, Secure Enclave key storage, and iCloud sync. Termius also supports SSH with auto-reconnection on both iOS and Android. On Android, Termux with mosh installed is a free alternative.

Can I use the same tmux session from my Mac and iPhone simultaneously?

Yes. tmux supports multiple simultaneous clients on the same session. Both devices see identical output in real time. You can type from either device. Use tmux attach -t work from each one.

What UDP ports does Mosh need open on the server?

Mosh uses UDP ports 60000-61000, consuming one port per concurrent session. If you only expect a few sessions, opening a smaller range like 60000-60010 in your firewall is enough.

What Builders Are Making With Claude Code, Codex, and Gemini CLI
Three terminal tools now let developers build entire applications through conversation. Anthropic's Claude Code, OpenAI's Codex CLI, and Google's Gemini CLI each take a different approach to the same
OpenAI Launches Codex Desktop App for macOS With Multi-Agent Workflows and Doubled Rate Limits
OpenAI released a macOS desktop app for Codex today, turning its AI coding agent into a standalone application that can run multiple agents across different projects at the same time. The company also
Anthropic's Cowork Strips the Developer Costume Off Claude Code
Simon Willison has been saying it for months. Claude Code, the terminal-based agent that Anthropic marketed to programmers, was never really a coding tool. It was a general-purpose agent that happened
Tools & Workflows

San Francisco

Editor-in-Chief and founder of Implicator.ai. Former ARD correspondent and senior broadcast journalist with 10+ years covering tech. Writes daily briefings on policy and market developments. Based in San Francisco. E-mail: [email protected]