Running Claude Code on a remote machine over SSH

Running the agent next to the code is usually right, and when the code lives on a server, so should the agent. Two things make that pleasant instead of painful: a login that completes without a local browser, and a session that outlives your connection.

By the Continuum team. We build a workbench that runs Claude Code, Codex, and their peers, so the model rates quoted here are the ones our own cost analytics ship with.

The short version

Install Claude Code on the remote host, not locally against a mounted filesystem. Sign in by running claude and pasting back the login code the browser shows, which is the normal path over SSH, or use claude setup-token and CLAUDE_CODE_OAUTH_TOKEN for an unattended box. Always run inside tmux so a dropped connection does not kill the session. Latency comes from the model round trip, not from SSH, so a remote agent feels no slower than a local one.

What you need to know
  • Install on the remote host, never locally against SSHFS or a network mount.
  • Browser login works over SSH: paste the code the browser shows back into the terminal.
  • For unattended boxes, claude setup-token then CLAUDE_CODE_OAUTH_TOKEN.
  • Always tmux. SSH drops eventually, and it drops mid-edit.
  • SSH adds tens of milliseconds against a model round trip measured in seconds.
  • claude --remote-control lets you check in from a phone without another SSH client.

Setting it up

01

Install on the remote host

ssh you@server
curl -fsSL https://claude.ai/install.sh | bash
exec $SHELL -l
claude doctor

The native installer needs no Node.js and installs into your home directory, so no root is involved. On Debian, Ubuntu, Fedora, RHEL or Alpine you can install from the signed package repositories instead, which fits better if the box is configuration-managed.

02

Sign in without a local browser

Run claude and follow the prompt. The browser cannot reach the callback server inside your SSH session, so it shows you a login code instead of redirecting. Paste that code at the Paste code here if prompted prompt. This is the expected path over SSH, not a workaround, and it keeps the session on your subscription.

# no browser at all, or an unattended box
# on your laptop:
claude setup-token

# on the server:
export CLAUDE_CODE_OAUTH_TOKEN="<token>"
claude

The token lasts a year, is printed once and never saved, and requires a paid plan. For genuinely automated work, use ANTHROPIC_API_KEY instead: a subscription is licensed for interactive use by one person, and a cron job is not that.

03

Run inside tmux

tmux new -s agent
cd ~/projects/thing
claude

# detach with ctrl-b d, then later:
tmux attach -t agent

Without this, closing your laptop kills the agent mid-edit. With it, you reattach and the session is exactly where you left it.

Surviving a bad connection

ToolSurvivesNotes
tmuxDisconnects, laptop closing, reboots of your machineEssential. Non-negotiable, really.
moshRoaming, high latency, sleepLocal echo makes typing feel instant
ssh -o ServerAliveInterval=30Idle timeoutsStops NAT quietly dropping the connection
autosshReconnecting automaticallyBelt and braces on top of tmux
~/.ssh/config, for connections that stay up.
Host devbox
  HostName 10.0.0.5
  User you
  ServerAliveInterval 30
  ServerAliveCountMax 6
  ControlMaster auto
  ControlPath ~/.ssh/cm-%r@%h:%p
  ControlPersist 10m

Where the latency actually is

People expect a remote agent to feel sluggish and are surprised when it does not. The reason is the ratio.

Rough contributions to the time between prompt and reply.

ComponentTypical
SSH round trip10 to 80 ms
File reads on the remoteFast; they are local to the agent
Model round trip2,000 to 30,000 ms

The same logic applies inside WSL, where working on /mnt/c from a Linux-side agent crosses a translation layer on every read. Different mechanism, identical symptom: everything is fine except that it is inexplicably slow.

One turn spends tens of milliseconds on SSH and seconds on the model, so the agent belongs on the machine that holds the files rather than reading them over the network one turn on a remote box, prompt to reply one turn SSH 10 to 80 ms model round trip · 2,000 to 30,000 ms a rounding error next to the model agent where the files are your laptop remote host agent and the repo one SSH hop per turn file reads never leave the box agent local, files over SSHFS your laptop the agent runs here x400 the repo every file read pays the hop hundreds of them per turn Put the agent where the files are. The same rule explains /mnt/c inside WSL.

Checking in without another SSH client

The awkward part of a remote agent is not running it, it is knowing when it wants something. Remote Control closes that gap: the session keeps running on the server, and you steer it from a browser or the Claude mobile app.

Inside tmux on the remote host.
claude --remote-control "api migration"

# or, from inside a session already running
/remote-control

What the model is, and what it is not. As of August 2026, research preview.

PropertyDetail
Where code runsStill the remote host; the browser is a window
Inbound portsNone. The session makes outbound HTTPS requests only
CredentialA claude.ai login. API keys and setup-token tokens are refused
EndpointRequires api.anthropic.com; a custom ANTHROPIC_BASE_URL disables it
If the process diesThe session ends, which is why tmux still matters
Network outageReconnects automatically; roughly 10 minutes offline ends it

While Remote Control is connected, the transcript is stored on Anthropic servers so the conversation stays in sync across devices. Execution and filesystem access stay on your machine. If that trade is not one you want on a particular host, the setting to turn it off entirely is disableRemoteControl.

Working across several machines

Once agents are running on more than one host, the problems stop being technical and become organisational: which box is running what, whether the long job finished, and how to read a diff without opening a shell to look.

Number of hostsWhat works
1tmux, one window per session
2 to 3tmux plus named SSH config entries and ControlMaster
Several, plus a laptopA workbench that aggregates sessions across hosts

Questions people ask

Install it on the remote host with the native installer, sign in by pasting the login code the browser shows, and run it inside tmux so the session survives a dropped connection.

Run claude and paste the login code the browser displays at the Paste code here if prompted line. That is the normal path over SSH. For an unattended box, run claude setup-token on a machine with a browser and set CLAUDE_CODE_OAUTH_TOKEN on the server.

Only if you started it inside tmux or screen. Otherwise the process is killed with the shell, potentially mid-edit. Detach with ctrl-b d and reattach with tmux attach.

No. SSH adds tens of milliseconds against a model round trip measured in seconds. What is slow is running the agent locally against a remote filesystem, where every one of hundreds of file reads pays the network cost.

No. The agent reads constantly and every read would cross the network. Install it on the machine that holds the files, and use SSH only to reach the terminal.

Yes. Start it with claude --remote-control, or run /remote-control in a running session, and open it from claude.ai or the Claude mobile app. It makes outbound HTTPS requests only and opens no inbound ports, and it needs a claude.ai login rather than an API key.

Most often because the box is authenticated with CLAUDE_CODE_OAUTH_TOKEN or an API key. Those credentials can make model requests but cannot establish a Remote Control session. A custom ANTHROPIC_BASE_URL also disables it.

Yes. Beyond a couple, the difficulty is keeping track of them rather than running them, which is what a workbench that aggregates sessions across hosts is for. Give each session its own git worktree so agents on one box do not collide.

Sources

Every figure above was read from these pages on August 2026. Vendors reprice without notice; if you find a stale number, tell us.

  1. Claude Code setup and install
  2. Claude Code authentication
  3. Claude Code Remote Control
  4. Claude Code CLI reference
Try it

Every host,
one sidebar.

Continuum runs agents on remote Linux and Mac boxes over Tailscale and shows every session, diff and PR in one place, on your Mac and your phone.

free app · your subscriptions · local-first