{"slug": "how-to-run-ai-coding-agents-on-a-server-from-your-iphone-over-ssh", "title": "How to Run AI Coding Agents on a Server From Your iPhone (Over SSH)", "summary": "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.", "body_md": "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.\n\nWhat 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.\n\n## Can you SSH into a server from your phone to run an AI agent?\n\nYes. You need three things:\n\n- A server where the agent runs: a cloud VPS, a home server, a Raspberry Pi, or a spare Mac.\n- An SSH client on iOS: a terminal app that can hold a real interactive session.\n- The agent installed and authenticated on that server (for Claude Code, an Anthropic subscription or API key).\n\nThat'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.\n\n## How do you reach the server from your phone?\n\nYour 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:\n\n**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.\n\nThis 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.\n\n## How do you keep the agent running when your iPhone disconnects?\n\nStart 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.\n\nThe fix is a terminal multiplexer. Start the agent inside **tmux** (or screen) so it runs on the server independently of your connection:\n\n`tmux new -s agent`\n\nLaunch the agent inside that session. Now when your connection drops, the agent keeps working. Reconnect and reattach:\n\n`tmux attach -t agent`\n\n**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.\n\n## What's the full setup to run an agent from your phone over SSH?\n\nPut together, the do-it-yourself mobile setup for a box behind NAT is five steps:\n\n**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.\n\nIt 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.\n\n## Why is running an agent from a phone harder than from a laptop?\n\nThe 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:\n\n**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`\n\nand 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.\n\nThe 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.\n\n## Is there a way to skip the manual SSH and tmux setup?\n\nYes: 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).", "url": "https://wpnews.pro/news/how-to-run-ai-coding-agents-on-a-server-from-your-iphone-over-ssh", "canonical_source": "https://onepilotapp.com/blog/run-ai-agents-iphone-ssh", "published_at": "2026-06-27 00:00:00+00:00", "updated_at": "2026-06-27 21:42:35.862973+00:00", "lang": "en", "topics": ["ai-agents", "developer-tools", "ai-tools"], "entities": ["Claude Code", "Codex", "Anthropic", "Hetzner", "DigitalOcean", "EC2", "Fly.io", "Tailscale"], "alternates": {"html": "https://wpnews.pro/news/how-to-run-ai-coding-agents-on-a-server-from-your-iphone-over-ssh", "markdown": "https://wpnews.pro/news/how-to-run-ai-coding-agents-on-a-server-from-your-iphone-over-ssh.md", "text": "https://wpnews.pro/news/how-to-run-ai-coding-agents-on-a-server-from-your-iphone-over-ssh.txt", "jsonld": "https://wpnews.pro/news/how-to-run-ai-coding-agents-on-a-server-from-your-iphone-over-ssh.jsonld"}}