Skip to content
COL0

Claude Code on a VPS: install and use it from your server

Claude Code is a coding assistant that works from the terminal. On a VPS you can edit and debug your app right where it runs, without depending on your own computer.

Written by Victor Barrera

The concepts you need

  • VPS: your own Linux server that you reach over SSH. If you don’t have one yet, start with Linux VPS from scratch.
  • tmux: keeps your session alive even if the SSH connection drops.

The steps, in short

Replace YOUR_VPS_IP with your server’s IP and YOUR_REPO_URL with your repository.

  1. Check the requirements: Ubuntu LTS (22.04 or 24.04; the docs ask for 20.04+), 4 GB of RAM, a compatible Claude account and root access with an SSH key. If the VPS only has a password, create and copy your key from your computer:
ssh-keygen -t ed25519
ssh-copy-id root@YOUR_VPS_IP
# On Windows (PowerShell), use this:
type $env:USERPROFILE\.ssh\id_ed25519.pub | ssh root@YOUR_VPS_IP "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
  1. Create an unprivileged user with sudo. Log in as root. adduser asks for a password for sudo.
adduser deploy
usermod -aG sudo deploy
rsync --archive --chown=deploy:deploy ~/.ssh /home/deploy

Verify: from your computer, ssh deploy@YOUR_VPS_IP must log in with the same key.

  1. Install tmux, git and Claude Code as deploy, not as root. In a new terminal, tmux -V and claude --version must show a version:
sudo apt update && sudo apt install -y tmux git curl
curl -fsSL https://claude.ai/install.sh | bash
  1. Open tmux and bring your project: tmux new -s claude, git clone YOUR_REPO_URL and go into the folder. If it is private, use a read-only deploy key and clone over SSH. To leave without killing the session: Ctrl+b, then d; to come back: tmux attach -t claude.
  2. Set manual mode and protect secrets, before opening claude. Without this, claude starts in auto, where another model approves, not you (Shift+Tab only changes the current session). From the project folder:
mkdir -p .claude
echo '{ "permissions": { "defaultMode": "default", "deny": ["Read(**/.env)", "Read(**/.env.*)"] } }' > .claude/settings.local.json

The rules do not cover grep -r or scripts: keep the real .env outside the project (point your app to it) and approve every command.

  1. Sign in: run claude --permission-mode default and open the login URL in the browser on your computer. If it wraps across several lines, press c; if it does not reach your clipboard, select it with the mouse. If it shows a code, paste it where it says Paste code here if prompted. You will see Login successful and, below, manual mode on.
  2. Work carefully: read each command before approving and avoid accept edits on (it approves rm, mv, cp, sed). Use a branch, review with git diff and back up the database and .env.
  3. Close the SSH door only once your key works. The 00- prefix makes this file win: sshd uses the first value it reads:
printf 'PasswordAuthentication no\nKbdInteractiveAuthentication no\n' | sudo tee /etc/ssh/sshd_config.d/00-hardening.conf
sudo sshd -t
sudo systemctl restart ssh
sudo sshd -T | grep -E 'passwordauthentication|kbdinteractiveauthentication'

It must show no on both; if it shows yes, another file wins. Do not close this session: try ssh deploy@YOUR_VPS_IP in another terminal.

  1. Turn on the firewall. Never open database ports:
sudo ufw allow 22/tcp
# only if you serve a website:
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable  # answer y when it asks

Common mistakes

  • Killed or code 137 during install: out of memory. Add swap with the commands in the official docs and repeat step 3.
  • claude: command not found: the terminal does not look in ~/.local/bin, where it is installed:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc && source ~/.bashrc

How we help

We set up your VPS with users, SSH keys, a firewall and Claude Code, and teach you a safe workflow to change your app without breaking production.

Checked against the official documentation (Claude Code 2.1.283 or later), October 2026.

Frequently asked questions

What does Claude Code require on a server?

According to its documentation: Ubuntu 20.04+ or Debian 10+, at least 4 GB of RAM, an x64 or ARM64 processor, an internet connection and a Pro, Max, Team, Enterprise or Console account (the free claude.ai plan does not include Claude Code). This guide assumes Ubuntu LTS.

Is it safe to use Claude Code directly on production?

Do it carefully: use an unprivileged user, work on a branch with a backup, and set manual mode (manual mode on) so you approve every action. The accept edits mode also approves rm, mv, sed and similar. For big changes, test in staging first.

How do I know it installed correctly?

Open a new terminal and run claude --version. For a fuller check, use claude doctor.

How do I sign in if my VPS has no browser?

Run claude --permission-mode default, select the login URL with the mouse and open it in the browser on your computer. If it shows a code instead of redirecting, paste it into the VPS terminal, where it says Paste code here if prompted.

Want your VPS ready for Claude Code?

We set up users, SSH keys, a firewall and Claude Code, and teach you a safe workflow to change your app without breaking production. You need your own compatible Claude account.

Tell us about your Claude Code setup