How to Run AI Coding Agents on a Server From Your iPhone (Over SSH) Users can run AI coding agents like Claude Code on a remote server from an iPhone via SSH, but the setup requires a server with a public IP or a Tailscale tunnel for NAT, a terminal multiplexer like tmux to keep agents running after disconnection, and an iOS SSH client. The process works but involves friction from network and session management challenges. The agent runs on the server. That single fact is what makes this possible at all: Claude Code https://claude.com/product/claude-code , Codex, and the rest are terminal programs that execute on a remote machine, so anything that can hold an SSH session can drive them, including the phone in your pocket. The appeal is obvious. An agent is chewing through a refactor, you're on a train, and you want to check it's not stuck on a prompt. You don't need a laptop for that. You need a terminal and a connection. What the "just SSH in from your phone" advice skips is that two unglamorous problems sit between you and that terminal, and both get harder on mobile. Here's the honest version of how this actually works. Can you SSH into a server from your phone to run an AI agent? Yes. You need three things: - A server where the agent runs: a cloud VPS, a home server, a Raspberry Pi, or a spare Mac. - An SSH client on iOS: a terminal app that can hold a real interactive session. - The agent installed and authenticated on that server for Claude Code, an Anthropic subscription or API key . That's the easy part. The agent's interactive UI file diffs, tool calls, approval prompts renders in the terminal the same on a phone as on a desktop. The work is in the two problems below. How do you reach the server from your phone? Your phone has to open a TCP connection to the server's SSH port, and how hard that is depends entirely on where the box lives: A cloud VPS Hetzner, DigitalOcean, EC2, Fly.io, … has a public IP . You connect straight to it from anywhere. No tunnel, no extra setup. A machine behind NAT , say a Mac mini in your closet, a Pi, or your work laptop, has no public address . From outside your home network you can't reach it directly. The standard fix is to put it on a private network like Tailscale https://tailscale.com/ or a tunnel and reach it over SSH on its tailnet address. This is worth being clear about because a lot of "run agents from your phone" guides quietly assume it away: if your server is behind NAT, you need Tailscale or an equivalent regardless of which iOS app or tool you use. It's not a quirk of one client; it's how networking works. The only setups that skip it are the ones pointed at a public-IP VPS. How do you keep the agent running when your iPhone disconnects? Start it inside a terminal multiplexer like tmux, so it keeps running on the server even when your phone drops the connection. This is the part that bites people: a bare SSH session is tied to the connection, so the moment your phone locks, hands off from Wi-Fi to cellular, or backgrounds the app, that session can drop, and a long-running agent started in it goes down with the shell. You come back to a dead connection and a half-finished task. The fix is a terminal multiplexer. Start the agent inside tmux or screen so it runs on the server independently of your connection: tmux new -s agent Launch the agent inside that session. Now when your connection drops, the agent keeps working. Reconnect and reattach: tmux attach -t agent Mosh helps on top of this: it's a UDP-based SSH replacement built for high-latency, flaky mobile links, and it keeps your client session glued together across network changes so you're not re-authenticating every time the train enters a tunnel. What's the full setup to run an agent from your phone over SSH? Put together, the do-it-yourself mobile setup for a box behind NAT is five steps: Install Tailscale on the server and on the phone; bring both up on the same tailnet. Enable SSH on the server and ideally Mosh . Install an iOS SSH client and add the host by its tailnet address with key-based auth. Start the agent in tmux so it survives disconnects. Reattach whenever you want to check in. It works. People do exactly this every day, and for a single box it's a perfectly reasonable afternoon of setup. The friction shows up later. Why is running an agent from a phone harder than from a laptop? The agent runs identically either way; the friction is all in the phone holding a usable terminal. None of these are dealbreakers, but they stack up: Reconnect tax. Every lock-screen is a reconnect-and-reattach. Mosh softens it; it doesn't remove it. The keyboard. Typing tmux attach -t agent and navigating panes on a glass keyboard is the opposite of ergonomic. No native signal. When the agent finishes or pauses to ask for approval, nothing tells you. You find out by reopening the app and scrolling. Several agents at once. Two or three tasks across two or three servers means juggling named tmux sessions and host entries by hand. The terminal was designed for a keyboard and a stable link. A phone has neither. That gap, not the SSH itself, is what makes the manual setup feel like ceremony. Is there a way to skip the manual SSH and tmux setup? Yes: a phone-first app built for exactly this loop closes most of the gap. Onepilot / connects to your server over plain SSH, so the security model is the same battle-tested one, and a box behind NAT still rides on Tailscale just like above; but it folds away the parts that fight your phone: session persistence without hand-rolled tmux, native iOS push when an agent needs you, a real touch-friendly terminal with a file browser and git, and one place to switch between Claude Code, Codex, OpenClaw, and Hermes across every server you run. It doesn't replace your desk; it just means a locked phone and a flaky train connection stop being the reason an agent sits waiting. If you want the step-by-step for one agent, see running Claude Code on iPhone /blog/claude-code-iphone , or the broader playbook for managing several agents at once /blog/manage-ai-agents-iphone .