Guide

Run Claude Code on a remote server with tmux

Close the laptop and Claude Code stops with it. Run it on a machine that stays on, inside tmux, and it keeps working while you're away.

The short version

On any Linux or macOS machine you can SSH into (a cloud server, a spare Mac mini, a VM):

# once, on the server
sudo apt install tmux                          # or: brew install tmux
curl -fsSL https://claude.ai/install.sh | bash

# every time, from your laptop
ssh -t devbox tmux new -A -s claude            # creates or reattaches
cd ~/src/myapp && claude

Give Claude its task, detach with Ctrl+b d, and close the laptop. Run the same ssh line later, from any computer, to land back in the session with everything it printed meanwhile.

Logging in without a browser

Run claude, press c to copy the login URL, open it on your laptop, and paste the code it shows back into the terminal. For a server you'd rather not log in on, create a token with claude setup-token on your laptop and set it there as CLAUDE_CODE_OAUTH_TOKEN (docs).

Good to know

With Komla

Plain tmux gets fiddly once several agents run there: nothing tells you which window is waiting for you, and every task needs its own worktree and tunnel. Komla's SSH workspaces do that part:

Komla with two agents working on the devbox SSH host and a page open on a forwarded port

The same works for Codex CLI, OpenCode and the other supported agents.

Related guides

Get notified when Claude Code or Codex finishes and run multiple AI coding agents with git worktrees.

Komla is free and open source for macOS, Windows and Linux. Download Komla.