How to run Claude Code on a server
Rent a small Linux server, install Claude Code, sign in, and start it inside tmux so it survives when you disconnect. You reach it over SSH from any machine, and it keeps working with your laptop closed.
Step by step
- Get a server. Any Linux server you can reach over SSH will do. Size it for the project rather than for Claude Code: the builds and tests it runs decide how much memory you need.
- Install Claude Code. Follow the installer in Anthropic's documentation, then clone your repository onto the server and install its dependencies so the agent can build and test it.
- Sign in. Run claude. The server has no browser, so open the sign-in link it prints on your laptop and paste the code it gives you back into the terminal.
- Start it inside tmux. Run tmux new -s claude, start claude in your repository, then detach with Ctrl-b d. The session keeps running after you log out.
- Come back to it. From any machine, ssh to the server and run tmux attach -t claude. You land in the same session, where the agent left it.
What you take on
The server is yours to keep: system updates, a firewall, disk space, and a backup of anything that is not pushed. The agent runs commands as the user it runs as, so that user should hold the project’s credentials and nothing more.
One checkout serves one agent. A second agent needs a git worktree of its own, with its own install and its own ports, or the two will write over each other.
When a hosted option is less work
If the point is only to keep Claude Code running with the lid closed, Anthropic’s cloud sessions do that without a server, for tasks that end in a pull request on GitHub. If you want the real terminal, Codex next to Claude Code, and teammates watching the same session, Murmell runs it on a cloud machine with nothing to install. Run Claude Code in the cloud puts the four options side by side.
Straight answers
Does Claude Code keep running after I close my SSH connection?
Only if it runs inside a terminal multiplexer such as tmux or screen. Started directly in the SSH session, it stops when the connection drops.
Can several Claude Code agents share one server?
Yes. Give each one its own tmux window, and its own git worktree or checkout, so two agents never write the same file at the same time.
Is it safe to let Claude Code run commands on a server?
It can run anything the user it runs as can run. Use a dedicated user, keep only the credentials the project needs on the machine, and do not put it on a server that holds production data.