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
-
Reboots end tmux, not the conversation:
claude --continuepicks up the last one in that folder. - Several agents? Give each its own git worktree and tmux window, so they don't edit the same files.
-
Dev servers:
ssh -N -L 3000:localhost:3000 devbox, then openlocalhost:3000on your laptop. - Keys: give the server its own Git key scoped to its repositories instead of forwarding your SSH agent, and keep unattended runs that skip permission prompts to a VM with nothing else on it.
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:
- Add the host from
~/.ssh/config; Komla needs no sudo and no packages. - Each workspace is a worktree on the host, its terminals in tmux. Quit Komla and the agents keep working; reopen it, or another computer, and they're where you left them.
- Agents that finish or need input are badged, and the notification reaches your computer.
- Dev-server ports are tunneled for you, and diffs open in the app.
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.