Installing Claude Code on a VPS: Requirements, Login Methods, and Persistent Sessions
Overview
Claude Code is a command-line coding assistant released by Anthropic. It reads and writes project files and runs commands in the terminal. The YouTube video “How to Put Claude Code on a VPS in 10 Minutes” demonstrates installing it on a VPS so that it can run long-term without depending on a local computer. When the video’s subtitles were fetched, YouTube returned LOGIN_REQUIRED, so the source material includes only the title and description. The commands and requirements below come from the official Claude Code documentation. The exact sequence of steps shown in the video is not verified.
Use Cases
Claude Code installed on a VPS can keep running long tasks after the local computer is shut down, and it can edit configuration and read logs directly in the server environment. Connecting to the server over SSH from a phone or tablet allows continuing in the same session. The “10 minutes” in the video title is the creator’s claim. Actual time depends on machine specs and network conditions, and this article has not verified it.
Prerequisites
The system requirements in the Claude Code documentation include Ubuntu 20.04 or later or Debian 10 or later, and at least 4 GB of RAM. Installing with npm also requires Node.js 18 or newer. Many entry-level VPS plans have only 1 GB or 2 GB of RAM, which is below the 4 GB in the documentation. Whether such machines run Claude Code reliably needs to be tested.
One of two account types is required: a Claude Pro or Max subscription, or an Anthropic Console account billed by API usage.
The video description promotes Hostinger VPS with the promo code NATEHERK, which gives 10% off annual plans, at hostinger.com/nateherk10. This is an affiliate link, and using a different VPS provider does not change the installation process. The description also mentions a free setup document, but the link in the source material is truncated, so its contents could not be checked.
Installation Steps
After logging in to the VPS, check the Node.js version first. If the output is below v18, upgrade before continuing:
node --version
Install globally with npm:
npm install -g @anthropic-ai/claude-code
The official documentation advises against installing with sudo npm install -g to avoid permission problems and security risks. If permission errors occur, the documentation recommends changing the npm global prefix to a directory under the user’s home, or using nvm to manage Node.js.
The documentation also provides a native install script that does not depend on Node.js:
curl -fsSL https://claude.ai/install.sh | bash
After installation, check the version and installation status:
claude --version
claude doctor
claude doctor checks the installation type and auto-update status. When errors appear, its output is the first place to look.
Login and Authentication
Run claude from the project directory to start it. The first run guides you through login, and /login can be used inside a session later to switch accounts. A VPS has no graphical interface, so the login flow prints a URL. Open the URL in a browser on the local machine, authorize access, then paste the returned code back into the terminal. How this flow behaves on a headless server is not verified.
With Console API billing, the key can be supplied through the ANTHROPIC_API_KEY environment variable instead. Store the key in a shell config file or a separate environment file, and do not commit it to a Git repository.
Configuration
Claude Code settings files have three levels. User-level settings live in ~/.claude/settings.json. Project-level settings live in .claude/settings.json at the project root. Local settings that apply only to you and are not committed go in .claude/settings.local.json. Permission rules go in the allow and deny lists under the permissions field. These lists define which commands can run without confirmation and which commands are always blocked.
The CLAUDE.md file at the project root is read at the start of every session. It can hold project conventions, common commands, and notes on the directory layout.
When the SSH connection drops, a Claude Code process running in the foreground exits with it. A common approach is to run it inside a tmux session:
tmux new -s claude
claude
After a disconnect, run tmux attach -t claude to reattach. tmux is a general-purpose Linux tool, and whether the video uses this approach is not verified.
Limitations and Caveats
- Use of Claude Code is governed by Anthropic’s consumer terms or commercial terms. Subscribers share their Pro or Max usage limits with the Claude web app. Once the limit is used up, you need to wait for it to reset or switch to API billing.
- The
--dangerously-skip-permissionsflag skips all action confirmations. The official documentation recommends it only inside containers without internet access. If this flag is enabled on an internet-connected VPS that runs other services, any command Claude Code executes acts directly on the whole machine. - Create a regular user to run Claude Code instead of using root directly. A single mistake under root can affect the entire server.
- While running, Claude Code sends code and command output to Anthropic’s servers for processing. If the repository contains keys or customer data, confirm first that this content is allowed to leave the server.
- Check the promo code, discount rate, and prices on the Hostinger website, since these terms may have changed since the video was published.
Items to Test
- Claude Code memory usage at idle and while running tasks on 1C1G and 2C4G machines
- Differences in time and results between the npm install and the native install script on the same VPS
- Whether URL-based authorization login completes successfully in a headless environment
- Whether Claude Code keeps its conversation context after reconnecting to a tmux session
- Total time from provisioning the VPS to completing the first conversation, compared with the 10 minutes in the video title