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.

Rule of thumb

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.

Frequently asked questions

How much RAM does Claude Code need on a VPS?
The CLI itself is light — 2 GB is workable. What actually decides it is your project: builds, test suites, containers and databases are the memory-hungry parts. 4 GB is a comfortable default for one developer and one project.
Do I need an API key to run Claude Code on a server?
No. Run claude auth login and sign in with the Anthropic account behind your Claude Pro or Max subscription. There is no API key to manage and no metered usage on top.
How do I log in on a server with no browser?
claude auth login prints a URL you can open on any device. Authorise there and the login completes back on the server. Confirm with claude auth status, which exits non-zero when you are logged out — handy in scripts.
Is it safe to expose SSH to the internet?
With key-only authentication, root login disabled and something like fail2ban, it is standard practice and fine. If you would rather not expose it at all, put the server on a Tailscale network and reach it from your phone over that instead.
Can I use the same server from more than one device?
Yes. It is an ordinary machine over SSH, so a laptop terminal and a phone can both reach it. With Maude, sessions live in a server-side daemon, so the same session shows up on every device you have connected to that host.

Server ready?

Point Maude at it and start from your phone. iOS and Android.