# Keep a Claude Code session running on a remote box and steer it from your phone

> Run Claude Code inside tmux on a server, use mosh for flaky links, connect Remote Control so you can steer and approve from your phone, and keep your SSH keys out of the agent's reach.

- **Category:** [Coding](https://stepgleam.com/categories/coding)
- **Difficulty:** Intermediate
- **Time:** ~30 minutes
- **Tools:** Claude Code, tmux, mosh, Claude app
- **Reliability score:** 84/100
- **Steps:** 6
- **Last updated:** 2026-10-27
- **Published:** 2026-10-27

## Tools used

- [Claude Code](https://code.claude.com/docs/en/remote-control) — Runs on the server; Remote Control lets you steer it from elsewhere
- [tmux](https://github.com/tmux/tmux) — Keeps the session alive when SSH disconnects
- [mosh](https://mosh.org) — Keeps the terminal connection alive on bad networks
- [Claude app](https://code.claude.com/docs/en/mobile) — Steer the session and answer approvals from your phone

## What you'll get

A Claude Code session on a server that survives dropped connections, which you can steer and approve from your phone.

## Who this is for

Developers with a Pro, Max, Team or Enterprise Claude plan and a server or always-on machine they can SSH into.

## Before you start

Developers on Hacker News (October 2026) described how they keep coding agents working after the laptop lid closes. Claude Code's own docs fill in the Remote Control details. Some details nobody shared, such as one developer's systemd unit, are flagged as gaps rather than invented.

## Steps

### Step 1: Start Claude Code inside a named tmux session on the server

**Tool:** tmux

Claude Code's docs say: *"If you run `claude` from a terminal on a remote machine, start it inside `tmux` or `screen` to keep the session running after you disconnect from SSH."* One command attaches or creates the session, so you can rerun it after every drop: `ssh devbox -t tmux new-session -A -s agents`.

**Why this works:** The tmux server owns the terminal, so the agent keeps working when your connection or laptop goes away.

**Prompt:**

```
ssh devbox -t tmux new-session -A -s agents
```

[Open step 1](https://stepgleam.com/guides/keep-a-remote-claude-code-session-alive-with-tmux-mosh-and-remote-control#step-1)

### Step 2: Use mosh if your connection keeps dropping

**Tool:** mosh

One developer's daily setup: *"ghosty + ssh + mosh + tmux + claude code (sometimes codex)."* He is honest about what still hurts: copy-paste works about 95% of the time, and pasting or dragging images and videos into the remote session does not work well. The tmux guide's advice: pair tmux with mosh *"if your link is bad enough that SSH itself keeps dying."*

[Open step 2](https://stepgleam.com/guides/keep-a-remote-claude-code-session-alive-with-tmux-mosh-and-remote-control#step-2)

### Step 3: Turn on Remote Control for the session

**Tool:** Claude Code

In the project directory on the server, run `claude remote-control` (server mode, which shows a URL and, on spacebar, a QR code). Or inside a running session, type `/remote-control` to carry the current conversation over. Then open the session at claude.ai/code or in the Claude app under Code. Requirements from the docs: a Pro, Max, Team or Enterprise plan with claude.ai sign-in; *"API keys are not supported"*; it does not work through Bedrock, Agent Platform, Foundry or a non-Anthropic `ANTHROPIC_BASE_URL`. On Team and Enterprise an Owner must enable it first.

**Why this works:** Execution and files stay on the server; only the conversation is relayed to your phone.

**Prompt:**

```
claude remote-control --name "My Project"
```

[Open step 3](https://stepgleam.com/guides/keep-a-remote-claude-code-session-alive-with-tmux-mosh-and-remote-control#step-3)

### Step 4: Set it up once per project on the server

**Tool:** Claude Code

A developer who drives Claude Code on servers from Desktop, mobile and web: *"The massive upside is that the actual work happens on the server so you can close your laptop and it will continue."* The cost: *"every new project requires a setup step on the server (to add the systemd service) where you will develop it since Claude can only handle one server per directory."* He did not share the unit file, so this guide does not either.

[Open step 4](https://stepgleam.com/guides/keep-a-remote-claude-code-session-alive-with-tmux-mosh-and-remote-control#step-4)

### Step 5: Get pinged on your phone, and isolate parallel sessions

**Tool:** Claude app

With Remote Control active, run `/config` and enable *"Push when actions required"* for permission prompts and questions, *"Push when Claude decides"* for finished tasks, or both. If you will open several sessions from your phone, start the server with `--spawn worktree` so *"each on-demand session gets its own git worktree."* If you stop the server, `claude remote-control --continue` brings the session back for about four hours.

**Prompt:**

```
claude remote-control --spawn worktree
```

[Open step 5](https://stepgleam.com/guides/keep-a-remote-claude-code-session-alive-with-tmux-mosh-and-remote-control#step-5)

### Step 6: Keep your SSH keys out of the agent's reach

**Tool:** tmux

One developer hands tmux sessions to Claude but keeps logins in his own hands: *"Paranoid me uses the macbooks secure enclave with fingerprint for the ssh key so claude can't ssh into my remote boxes by himself. I then open named tmux sessions, perform the ssh login via fingerprint, and then tell claude that he is free to take over that session with a given name."*

**Why this works:** The agent can work in a session you opened without being able to open new ones on its own.

[Open step 6](https://stepgleam.com/guides/keep-a-remote-claude-code-session-alive-with-tmux-mosh-and-remote-control#step-6)

## Pro tips

- Name tmux sessions after the project so tmux ls reads like an inventory.
- Remote Control needs claude.ai sign-in; it does not work with API keys, Bedrock, or a custom ANTHROPIC_BASE_URL.

## Common mistakes

- Starting claude directly in an SSH shell; when SSH drops, the session goes offline.
- Expecting a Remote Control session to survive a reboot or a stopped claude process; the docs say the process must keep running.

## FAQ

### Does Remote Control run my code in the cloud?

No. Per the docs, Claude keeps running on your machine; the web and mobile apps are a window into that local session.

### Is there a systemd unit I can copy?

The developer who runs one per project did not post it. Write your own or ask the agent to, then review it.

---

Canonical guide: https://stepgleam.com/guides/keep-a-remote-claude-code-session-alive-with-tmux-mosh-and-remote-control
Read this guide as Markdown: https://stepgleam.com/guides/keep-a-remote-claude-code-session-alive-with-tmux-mosh-and-remote-control.md
