Running Claude Code on a VPS
A small always-on server turns Claude Code from something tied to your laptop into something that keeps working while you don't. Here is a setup that is quick to stand up and sane to leave running.
Running Claude Code on a server rather than your laptop buys three things: it keeps working when your machine is closed, it survives a dropped connection, and it puts the agent somewhere disposable instead of somewhere with your SSH keys and browser profile on it. This guide covers a setup that takes about fifteen minutes.
You need a Claude Pro or Max subscription. Claude Code authenticates with that, so there is no API key to manage and no usage billed on top.
1. Choosing a box
Claude Code is not demanding by itself — it is mostly waiting on the network — but your project's toolchain might be. A rough guide:
- 2 GB RAM is enough for the CLI plus a modest project.
- 4 GB if you build anything substantial: a bundler, a test suite, a container or two.
- 8 GB+ if you run several sessions at once, or a database alongside them.
Hetzner, DigitalOcean, Scaleway, OVH, Vultr and Fly.io all work; so does an old machine under your desk. Pick a region near you — you will feel round-trip latency while typing. A €4–6/month ARM instance covers most single-developer use comfortably.
2. Create a non-root user
Do not run an agent as root on a box you care about. Make it a normal user first:
adduser dev
usermod -aG sudo dev
rsync --archive --chown=dev:dev ~/.ssh /home/dev
That last line copies the key you are already logged in with, so you can reconnect as dev before you lock anything down. Test it in a second terminal before closing the first — locking yourself out of a fresh VPS is a rite of passage worth skipping.
3. Harden SSH
The box is about to be reachable from your phone, so spend two minutes on this. In /etc/ssh/sshd_config:
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
Then sudo systemctl restart ssh. Key-based auth only, no root. If you want to go further, add fail2ban and a firewall that exposes only the SSH port. If the machine does not need to be on the public internet at all, put it on a Tailscale network and skip public exposure entirely — your phone joins the same network and reaches it directly.
4. Install Claude Code
Claude Code needs a current Node.js. Install it from nodejs.org or via nvm, then:
npm install -g @anthropic-ai/claude-code
claude --version
Install as your normal user, not with sudo. If npm wants root for a global install, point it at a user-owned prefix instead — a global npm tree owned by root is a recurring source of permission grief later.
5. Authenticate
Log in with your Anthropic account:
claude auth login
The CLI prints a URL. Open it in any browser — it does not have to be on the server, which is the point, since a VPS has no browser — authorise, and the session completes back on the machine. Check it with claude auth status.
The credential now lives in the server's home directory. Treat that box accordingly: anyone with shell access to it can use your Claude subscription.
6. Keep sessions alive
An SSH session dies with its connection, and so does anything running in the foreground. The traditional fix is tmux:
sudo apt install tmux
tmux new -s work
# ... start claude, then detach with Ctrl-B then D
tmux attach -t work
Detach, lose signal, reconnect later, reattach — the session is untouched. This is what most people mean by "Claude Code on a VPS", and it works well. Our guide on keeping work running goes further into the options.
7. Reach it from your phone
Two routes:
An SSH client. Termius, Blink or Prompt, attach to tmux, done. Free, complete, and you are driving a full-screen terminal UI with a soft keyboard — see how that setup actually feels.
Maude. Same SSH connection, rendered as an app: markdown messages, collapsible tool cards, native panels for slash commands, push notification when a task finishes, and sessions owned by a daemon so closing the app is not a disconnection. You add the host, its credentials and a project directory, and it handles the rest.
8. Decide on permissions
Now the interesting question: how much do you let it do unattended? A server is exactly the right place to relax permissions, because it is rebuildable — but only if you have actually treated it as disposable. That deserves its own page: running Claude Code with full permissions, safely.
Set the box up so that losing it entirely would be annoying rather than serious. Push your work to a remote regularly, keep no unique secrets on it, and assume you might rebuild it. Every decision above gets easier once that is true.