Run Claude Code on a remote server and manage it from your Mac

A server keeps agents working when your laptop is closed, gives them more CPU, and keeps them away from your personal files. This guide covers the whole setup: SSH, install and sign-in, keeping sessions alive, and seeing what the server's agents need from your Mac.

Last updated: · Cadence Labs

Short answer

SSH into the server, install Claude Code with curl -fsSL https://claude.ai/install.sh | bash, run claude once to sign in, and start your sessions inside tmux so they survive a dropped connection.

To see the server's agents from your Mac, run them in herdr and connect the server with herdr machine add. Or add it in Cadence 0.5.7 under Settings → Agents → Other machines, which puts its agents on your toolbar and in your Inbox next to the ones on your Mac.

Why run coding agents on a server

The cost is distance. Every session is one SSH hop away, and the usual signs that an agent is waiting, a bell or a banner, do not reach your Mac on their own. Most of this guide is about closing that gap.

Any Linux VPS or spare machine works. Claude Code supports Ubuntu 20.04 or later, Debian 10 or later and Alpine Linux 3.19 or later, with 4 GB of RAM or more on x64 or ARM64 (system requirements).

1. Set up SSH from your Mac

Use key-based login and give the server a short name. On your Mac:

# make a key if you don't have one
ssh-keygen -t ed25519

# copy it to the server
ssh-copy-id you@203.0.113.7

Then add a host alias to ~/.ssh/config:

Host devbox
    HostName 203.0.113.7
    User you

Now ssh devbox logs you in. herdr and Cadence both accept this alias.

2. Install and sign in to Claude Code

On the server:

curl -fsSL https://claude.ai/install.sh | bash
claude --version

Clone your project and run claude in it. The first run asks you to sign in. With no browser on the server, press c to copy the login URL, open it on your Mac, sign in, and paste the code back at the Paste code here if prompted line. On Linux the login is stored in ~/.claude/.credentials.json, readable only by your user (authentication).

For a box that only runs scripts, claude setup-token on your Mac prints a one-year token you can set as CLAUDE_CODE_OAUTH_TOKEN on the server. That token can only make model requests, so it cannot start Remote Control sessions.

Sessions on the server draw on the same plan as your Mac sessions when you sign in with the same account. The server also needs its own git access to push branches. A deploy key or a token scoped to one repository is safer than copying your personal key there.

3. Keep sessions running with tmux

A plain ssh devbox followed by claude ends when the connection drops. Start agents inside tmux instead:

ssh devbox
tmux new -s agents       # first window: run claude
# Ctrl-b c   new window for a second agent
# Ctrl-b w   list windows
# Ctrl-b d   detach; everything keeps running

tmux attach -t agents    # later, from any machine

Install tmux with the package manager (sudo apt install tmux on Debian and Ubuntu). If a session did end, claude --continue in the same folder picks up the most recent conversation. For two agents in one repository, give each its own worktree with claude --worktree <name>, as the multiple agents guide explains.

4. Use herdr and connect the server as a machine

herdr is a free, open-source terminal runtime built for coding agents. Like tmux, it keeps sessions running after you detach. It also reads each pane and marks the agent in it as working, blocked or idle. On the server:

curl -fsSL https://herdr.dev/install.sh | sh
herdr                  # starts or attaches to the default session
# Ctrl-b v   split right, then run claude or codex in the new pane
# Ctrl-b q   detach; the server and its agents keep running

herdr on your Mac can show that server next to your local agents. Check that ssh devbox works, then on your Mac:

herdr machine add devbox --label "Build box"
herdr machine list

Each machine keeps its own herdr server, so a lost connection or a sleeping laptop does not stop the agents on it. herdr reconnects on its own and shows the server's last known state dimmed until it does. To disconnect, run herdr machine remove <profile-id> with the id from herdr machine list. Details are in herdr's connecting machines docs.

5. Know when a server agent needs you

Hooks that post macOS notifications do nothing on a server, because it has no desktop. These do work:

6. Cadence 0.5.7: agents on other machines

Cadence is a free Mac app that puts every coding agent in one Inbox. Since version 0.5.7 that includes agents on your Linux servers, which Cadence reaches through herdr over your Mac's own SSH.

  1. In Cadence, open Settings → Agents → Other machines and copy the command it shows. It already contains your Mac's SSH public key:
    curl -fsSL https://cadencevoice.ai/machine.sh | sh -s -- ssh-ed25519 AAAA...
  2. Run it on the server. It installs herdr unless it is already there and adds your Mac's public key to ~/.ssh/authorized_keys, marked cadence. That is all it does. Nothing on the server connects to Cadence, its relay or your phone, and no token or password is involved. You can read the script before you run it.
  3. Back in Cadence, add the server by its SSH address, such as you@203.0.113.7 or an alias like devbox, with an optional name.
  4. On the server, start agents inside herdr: run herdr, then claude or codex in a pane.

The server's agents then get dots on the toolbar, cards in the Inbox and rows in the panel, labeled with the server's name. You answer their questions and send them messages from your Mac, or from your iPhone if you are in the iPhone beta.

Good to know:

Security basics

Common questions

Can Claude Code run on a VPS?

Yes. Claude Code supports Ubuntu 20.04 or later, Debian 10 or later and Alpine Linux 3.19 or later, with 4 GB of RAM or more on x64 or ARM64. Install it with the native installer and sign in over SSH by copying the login URL to a browser on another device.

How do I log in to Claude Code on a server without a browser?

Run claude, press c to copy the login URL, open it on your Mac or phone and sign in, then paste the code back at the Paste code here if prompted line. For scripts, claude setup-token makes a one-year token you set as CLAUDE_CODE_OAUTH_TOKEN.

Does Claude Code keep running after I disconnect from SSH?

Not on its own. A session started in a plain SSH shell ends when the connection drops. Start it inside tmux, screen or herdr, detach, and it keeps working until you come back.

What is a herdr machine?

A saved SSH connection from herdr on your computer to herdr on another box, added with herdr machine add. The remote workspaces and agents show next to your local ones, and they keep running on the box if the connection drops.

Can Cadence start agents on my server?

Not in 0.5.7. You start and end them on the server inside herdr. Cadence shows them on the toolbar and in the Inbox, and you answer and message them from your Mac or from the iPhone beta.