Claude Code is a command-line AI coding agent — you describe what you want, it writes, runs, and fixes real code in a real project. Running it on a small VPS instead of your laptop gives you an always-on, isolated environment your code lives on and you fully control. Here’s the full setup, from a blank server to a secure, ready-to-use box. Budget: about 15–20 minutes and ~$6/month for the server (plus your own Anthropic plan).
Step 1 — Create a VPS
Any Linux VPS works. I use DigitalOcean — a basic $6/month droplet (1 vCPU, 1 GB RAM) is plenty for Claude Code on small-to-medium projects; pick 2 GB if you’ll run databases or builds. (That link gives you $200 in free credit for 60 days, so the first couple of months are effectively free.)
- Create a droplet → choose Ubuntu 24.04 LTS.
- Plan: Basic → Regular → $6/mo (or $12 for 2 GB).
- Authentication: choose SSH key (far safer than a password). Paste your public key, or create one with
ssh-keygen -t ed25519on your computer and paste the contents of~/.ssh/id_ed25519.pub. - Create, then note the server’s IP address.
Step 2 — Connect and create a non-root user
From your computer’s terminal, connect as root, then create a normal user (running everything as root is a bad habit and a security risk):
ssh root@YOUR_SERVER_IP
# create a user and give it sudo
adduser dev
usermod -aG sudo dev
# copy your SSH key so you can log in as the new user
rsync --archive --chown=dev:dev ~/.ssh /home/dev
exit
Now log back in as that user: ssh dev@YOUR_SERVER_IP
Step 3 — Basic security (do this once)
# firewall: allow SSH only
sudo ufw allow OpenSSH
sudo ufw --force enable
# automatic security updates
sudo apt update && sudo apt install -y unattended-upgrades fail2ban
sudo systemctl enable --now fail2ban
# disable root SSH + password logins (keys only)
sudo sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin no/' /etc/ssh/sshd_config
sudo sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication no/' /etc/ssh/sshd_config
sudo systemctl restart ssh
That’s the 80/20 of server hardening: no root logins, no passwords, a firewall, auto-patching, and brute-force protection.
Step 4 — Install Node.js and Claude Code
Claude Code runs on Node.js (v18+). Install Node via nvm, then Claude Code from npm:
# install nvm + Node LTS
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
source ~/.bashrc
nvm install --lts
# install Claude Code
npm install -g @anthropic-ai/claude-code
# verify
claude --version
Step 5 — Authenticate
Make a project folder and start Claude Code:
mkdir ~/myproject && cd ~/myproject
claude
On first run it walks you through sign-in. The simplest option on a headless server is an API key: create one at console.anthropic.com, then set it before launching:
echo 'export ANTHROPIC_API_KEY="sk-ant-..."' >> ~/.bashrc
source ~/.bashrc
claude
If you have a Claude Pro/Max subscription, you can use that instead of API credits — the sign-in prompt gives you a link to authorize. Always check the current official steps at docs.claude.com/claude-code, since auth flows change.
Step 6 — Keep it running after you disconnect
Use tmux so long tasks survive you closing your laptop:
sudo apt install -y tmux
tmux new -s code # start a session; run `claude` inside it
# detach with Ctrl+b then d — the session keeps running
tmux attach -t code # reattach any time, from anywhere
Step 7 — Back up your work
Two layers. First, keep every project in git and push to a private GitHub repo — that alone protects your code. Second, for the whole server, snapshot it: DigitalOcean’s automated weekly backups are a $1.20/mo add-on (enable them when creating the droplet). For nightly off-server backups of your projects, restic to object storage is the gold standard.
You’re done
You now have an always-on, secured, backed-up AI coding environment that’s entirely yours. Open tmux, run claude, describe what you want to build, and it goes to work — on your server, with your code.
Frequently asked questions
Do I need to know Linux?
Not really — the setup above is copy-paste, and once Claude Code is running you mostly talk to it in plain English. Basic comfort with a terminal helps, but you can learn as you go.
How much does it cost per month?
The server is ~$6/mo (or ~$7.20 with weekly backups). On top of that you pay Anthropic directly — either a Claude subscription or API usage. There’s no SaaS middleman markup.
Is this safe?
With the Step 3 hardening (keys-only SSH, firewall, auto-updates, fail2ban) it’s well protected. The main ongoing risk is letting the agent run commands you haven’t reviewed — keep projects in git so you can always roll back.
Can someone just set this up for me?
Yes — that’s exactly the done-for-you setup service. I provision a secure, backed-up server with Claude Code ready to go, and keep it maintained, so you skip all of the above and just start building.
Want it done for you? A secure, backed-up Claude Code server, set up and maintained — you just write prompts.