Short answer: Install Claude Code on an Ubuntu or Debian VPS with at least 4 GB of RAM, run it as a normal user inside tmux so the session outlives your SSH connection, and authenticate with a key you've capped. That gives you an always-on coding box you can reach from a laptop, a phone or an iPad.
Disclosure: the Hostinger and AICredits links are affiliate links. The requirements, install commands and authentication behaviour come from Anthropic's setup page, read on 23 Oct 2026. I did not run Claude Code on a VPS for this post, so the tmux and server steps are standard but unrun here, and I didn't test the AICredits route with a specific Claude Code version.
The reason to do this is simple. Long agent runs, a build that takes twenty minutes, or a session you want to check from your phone all work better on a machine that never sleeps. The reason to be careful is just as simple: you're giving an AI agent a shell on an internet-connected server.
What does Claude Code need from the server?
From Anthropic's setup page:
- OS: Ubuntu 20.04+, Debian 10+ or Alpine 3.19+ (also macOS and Windows).
- Hardware: 4 GB+ of RAM, x64 or ARM64.
- Network: an internet connection.
- Shell: Bash, Zsh, PowerShell or CMD.
- Location: it lists "Anthropic supported countries" as a requirement, so check that yours is covered.
KVM 1 on Hostinger's page has 4 GB, which meets the minimum and leaves nothing for your project's own tools. KVM 2 (2 vCPU, 8 GB RAM) is the one I'd pick, since the project you're working on (a database, a build, a dev server) needs memory too. KVM 2 here.
How do you set up the server?
Start with a non-root user. Don't run an AI agent as root.
adduser dev
usermod -aG sudo dev
Copy your SSH public key to that user, log in as dev, and disable password login and root login once key access works. The hardening checklist lists the steps in order.
Then install Claude Code. The native installer, as given on Anthropic's page:
curl -fsSL https://claude.ai/install.sh | bash
Open a new terminal and check:
claude --version
claude doctor
claude doctor prints read-only diagnostics on installation and settings. The native install updates itself in the background. If you'd rather install through apt, the docs publish a signed repository and say to verify the key fingerprint before trusting it. If you prefer npm, it needs Node.js 22 or later, and the docs warn against sudo npm install -g.
How do you keep the session alive?
Install and use tmux:
sudo apt install tmux
tmux new -s work
claude
Detach with Ctrl+b then d. Close your laptop, lose Wi-Fi, switch to your phone. Later:
tmux attach -t work
The session continues because tmux owns the terminal, not your SSH connection. Put your project in a Git repository and commit often: a remote box with only uncommitted changes is one bad command from losing them.
How do you authenticate?
Three options per the docs:
- Log in with an account. Claude Code requires a Pro, Max, Team, Enterprise or Console account; the free claude.ai plan doesn't include it. You log in by running
claudeand following the browser prompts. On a headless server there is no browser, so the docs' Authentication page is where to look for the supported flow. I didn't test it. - Use an API key. Set
ANTHROPIC_API_KEY, approve the key when Claude Code asks, and it skips the login prompt. - Use a third-party provider such as Amazon Bedrock, Google Cloud's Agent Platform or Microsoft Foundry.
For Indian developers without an international card, there's another route: an OpenAI/Anthropic-compatible gateway. The Claude Code India guide walks through pointing Claude Code at AICredits so you pay in rupees by UPI. One thing to double-check: that guide's summary says the base URL has no /v1, while a later section shows one with /v1. Use the value on AICredits' own docs and confirm it works with a one-line test before you rely on it.
Whichever route you use, put the key in a file only your user can read, not in shell history:
install -m 600 /dev/null ~/.claude-env
echo 'export ANTHROPIC_API_KEY="sk-..."' >> ~/.claude-env
echo 'source ~/.claude-env' >> ~/.bashrc
Create the key with a spend limit. A runaway agent on a box that never sleeps can spend overnight.
What should you not do on this box?
- Don't put production credentials on it. Use a separate cloud account or a read-only token for anything real.
- Don't skip permission prompts casually. Approving commands is the guard rail. Claude Code can read web content and files, and text it reads can try to steer it, which is the prompt injection problem in practice.
- Don't expose extra ports. Reach dev servers through an SSH tunnel (
ssh -L 3000:localhost:3000 dev@server) instead of opening them to the internet. - Don't forget backups. Git remotes for code, and the Restic routine for everything else.
Is a VPS better than your laptop?
For long unattended runs and access from anywhere, yes. For a quick edit, your laptop is simpler and faster. A VPS also shares the cost of an always-on server with anything else you run, such as n8n. If you only need Claude Code a few hours a week, don't buy a server for it. More workflows are in the Claude Code track.



