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.
- 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"
- Create an unprivileged user with
sudo. Log in as root.adduserasks for a password forsudo.
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.
- Install tmux, git and Claude Code as
deploy, not as root. In a new terminal,tmux -Vandclaude --versionmust show a version:
sudo apt update && sudo apt install -y tmux git curl
curl -fsSL https://claude.ai/install.sh | bash
- Open tmux and bring your project:
tmux new -s claude,git clone YOUR_REPO_URLand 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, thend; to come back:tmux attach -t claude. - Set manual mode and protect secrets, before opening
claude. Without this,claudestarts inauto, where another model approves, not you (Shift+Tabonly 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.
- Sign in: run
claude --permission-mode defaultand open the login URL in the browser on your computer. If it wraps across several lines, pressc; if it does not reach your clipboard, select it with the mouse. If it shows a code, paste it where it saysPaste code here if prompted. You will seeLogin successfuland, below,manual mode on. - Work carefully: read each command before approving and avoid
accept edits on(it approvesrm,mv,cp,sed). Use a branch, review withgit diffand back up the database and.env. - 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.
- 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
Killedor 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.