Guide
How to run Claude Code on a VPS
On your laptop, Claude Code stops when the lid closes. On a small server it keeps going: long tasks finish overnight, and you look in from wherever you are. Here is how to set that up, by hand or with AgentKennel.
Why a server at all
Three reasons come up again and again:
- It keeps running. A task that takes an hour of tests and fixes doesn't care that you closed the laptop or lost Wi-Fi on a train.
- It is a separate machine. Agents that run commands without asking (Claude Code's
--dangerously-skip-permissions) are much safer on a box that holds nothing else of yours. - It is reachable. A server with a public address can be opened from any device, which is what makes checking in from a phone possible.
Pick a server
Any Linux VPS works for Claude Code itself. If you plan to use AgentKennel, choose Ubuntu 22.04, Ubuntu 24.04 or Debian 12 on x86_64 or aarch64: that is what its installer supports. Memory decides how many agents can be loaded at once, since each one is its own Claude Code process; you can usually move to a bigger plan later. Create a normal user with sudo rather than working as root.
The manual way: SSH and tmux
This is the classic setup and it works well for one or two sessions.
- SSH in and install Claude Code with the official installer from the Claude Code setup docs.
- Start a tmux session, for example
tmux new -s work, and runclaudeinside it. tmux is what keeps the process alive after you disconnect. - Sign in once; the authentication docs list the options (a Claude subscription or an API key).
- Detach with
Ctrl+BthenD, log out, and later reattach withtmux attach -t work.
If you want the agent to work without stopping for approval, Claude Code has permission modes for that, described in the permission modes docs. They note that Claude Code refuses to skip all checks when it runs as root or under sudo, one more reason for a normal user.
Where this gets tiring: every session is a separate thing to remember, attach and name. After a reboot you start and resume each one by hand. And from a phone you need an SSH app and a small keyboard.
The dashboard way: AgentKennel
AgentKennel is an open-source (AGPL-3.0) dashboard that does the tmux part for you and puts it in a browser tab. Each agent is still the real claude terminal in its own tmux session on your server; you just open it from a list instead of an SSH prompt. On a fresh VPS, as a normal user with sudo:
curl -fsSL https://raw.githubusercontent.com/yanhs/agentkennel/master/install.sh | bash
What you get, according to the project's README:
- HTTPS without a domain. A free
<ip-with-dashes>.sslip.ioname and a Let's Encrypt certificate, when ports 80 and 443 are free. - A one-time setup link to set the dashboard password, so a stranger who finds the fresh server first can't.
- Sessions that survive restarts. After a reboot every terminal reopens the same conversation (
claude --resume). - Many agents on one small server. At most 12 stay loaded; idle ones are unloaded and come back on click.
- Telegram and a phone-friendly view of the same terminals.
Don't want to SSH in at all? Paste a setup script while you create the server instead: there are step-by-step pages for Hetzner, DigitalOcean and Vultr.
Keep it safe
With prompts off, an agent can do in a second what takes a day to undo. A few habits help whichever way you run it:
- Use a VPS you don't share with anything important, or a container.
- Keep keys and tokens out of the repositories the agents push to.
- Give agents their own accounts and tokens with the smallest rights that work.
AgentKennel adds guards on top, as Claude Code hooks that check every shell command: no secrets or the server's IP in a commit, no pkill by pattern, no mail to people without your yes. If you want agents kept off the host entirely, its Docker sandbox runs them inside a container. The install page covers both.