OnepilotDownload
Onepilot mascot

How to Run AI Coding Agents on a Server From Your iPhone (Over SSH)

Run Claude Code and other AI coding agents on a remote server and steer them from your iPhone over SSH. The reachability problem, session persistence, and why the mobile setup is fiddlier than it looks.

sofiane8910

by sofiane8910 · June 27, 2026 · 8 min read

TL;DR

Claude Code and other AI agents run on the server, so any phone that can hold an SSH session can drive them. Two things make it work: reaching the machine (directly for a public-IP VPS, or over Tailscale for a box behind NAT) and keeping the session alive with tmux so a locked phone doesn't kill the agent. Here is the honest setup, and where it starts to chafe on mobile.

Onepilot runs these agents from your iPhone, download it on the App Store.

The agent runs on the server. That single fact is what makes this possible at all: 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:

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:

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:

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:

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, or the broader playbook for managing several agents at once.

FAQ

Can you run Claude Code from your iPhone over SSH?

Yes. Claude Code runs on a remote server, not on the phone. You SSH into the server from an iOS terminal app, start the agent inside a persistent session (tmux or screen), and watch it render in the terminal. The two things you have to solve are reaching the machine (directly if it has a public IP, or over a private network like Tailscale if it sits behind NAT) and keeping the session alive when your phone drops the connection.

Do I need Tailscale to run an agent from my phone?

Only when the machine is behind NAT, such as a home Mac mini, a Raspberry Pi, or a laptop on your home network. Those have no public address, so you put them on a private network like Tailscale (or a tunnel) and reach them over SSH. A cloud VPS with a public IP needs no tunnel; you connect straight to it. This is true whichever iOS SSH app or tool you use.

Why does my agent stop when my iPhone locks?

A bare SSH session is tied to the connection. When your phone sleeps, switches from Wi-Fi to cellular, or the app backgrounds, the session can drop and take the agent process with it. The fix is to start the agent inside a terminal multiplexer like tmux or screen so it keeps running on the server independent of your connection, then reattach when you reconnect. Mosh also helps by surviving network changes.

Is running an agent from a phone different from running it on a laptop?

The agent itself is identical; it runs on the server either way. The phone just has to reach the box and hold a usable terminal. The friction is mobile-specific: reconnect after every lock, a cramped on-screen keyboard for the SSH and tmux ceremony, no native push when the agent finishes or asks for input, and extra juggling when you run several agents at once.

Related reading

Run your AI agents from your iPhone

Download Onepilot on the App Store.

See also: the three-layer agent overview, run Hermes on iPhone, or all articles.