# How to Run Claude Code on a VPS

Create a remote coding environment you can reach through SSH, with the repository and credentials limited to the task. This workflow uses the native Claude Code installation path and keeps code review separate from agent execution.

Last updated: 2026-10-30

**01 / OUTCOME AND SCOPE**

## What this workflow covers

The target is an interactive coding workspace on a Linux VPS, not an unauthenticated web endpoint or an unattended production deployment agent. The repository and local tools run on the server; provider access is supplied through your own authorised account.

**02 / REQUIREMENTS AND COMPATIBILITY**

## Check the prerequisites first

Confirm compatibility and resources before running a command.

Use a Linux environment supported by the current Claude Code documentation, working outbound HTTPS access and a compatible account or provider arrangement. The native installer is the selected path here; do not introduce an npm/Node dependency merely because an older guide used it. Check repository size and tool processes when choosing resources.

**03 / SAFETY AND ACCESS BOUNDARIES**

## Plan permissions and network exposure

Security first: keep credentials, file access and administrative endpoints restricted.

Use a dedicated, non-root application account and grant only the permissions the workflow needs. Keep model-provider keys, repository credentials, messaging tokens and Virtarix management credentials separate. Do not give the agent unrestricted access to unrelated home directories or production systems.

Keep administrative interfaces private. A prompt, repository file, website or incoming message is untrusted input; it should not become authority to read secrets, widen permissions or perform destructive operations. Review tool permissions and require confirmation for consequential actions.

The VPS is the runtime environment, not an included model service. External provider use may create separate charges. Persistent execution must comply with the Acceptable Use Policy, including sustained CPU-use restrictions.

**04 / ENVIRONMENT PREPARATION**

## Prepare a controlled Linux environment

Start on a non-production Linux VPS and record its image, architecture and resource allocation. An administrator should prepare required system packages and recovery access; run the application itself from its own non-root account. Use the current upstream instructions for dependencies rather than installing a guessed runtime version.

Collect the basic environment information:

**Inside the VPS · Prepare a controlled Linux environment — Ubuntu · Bash**

```bash
id
uname -m
cat /etc/os-release
free -h
df -h "$HOME"
command -v curl
```

Stop when a dependency, supported architecture or resource requirement is not met. Do not continue by disabling a protection or silently choosing a different installation path. Keep a record of the version installed and the date of the check.

**05 / INSTALLATION AND COMPATIBILITY RESULT**

## Install Claude Code

Download the official installer, inspect it and run the stable-channel installation from the application account:

**Inside the VPS · Install Claude Code — Ubuntu · Bash**

```bash
curl --fail --silent --show-error --location https://claude.ai/install.sh --output install-claude.sh
less install-claude.sh
bash install-claude.sh stable
claude --version
claude doctor
```

If the command is not found, use the installer's PATH instructions and open a new shell. Do not bypass an unexplained installation warning. The version printed on your server is the version to record; no fixed example version is claimed here.

**06 / APPLICATION CONFIGURATION**

## Configure the application deliberately

Create a disposable repository before granting access to a real one:

**Inside the VPS · Configure the application deliberately — Ubuntu · Bash**

```bash
mkdir -p "$HOME/workspaces/claude-smoke-test"
cd "$HOME/workspaces/claude-smoke-test"
git init
printf '%s\n' '# VPS smoke test' > README.md
git add README.md
git -c user.name='Local Test' -c user.email='test@example.invalid' commit -m 'Create smoke-test repository'
claude
```

Complete the documented authentication flow. Begin with a read-only request to explain the file. Then allow one small edit inside this repository and review the proposed action. Do not give the application production deployment keys simply to complete the test.

**07 / FUNCTIONAL VERIFICATION**

## Verify function and the permission boundary

Run `git diff` after the approved edit and inspect exactly which files changed. Confirm that the provider account is the intended one and that a denied action remains denied. Run the project's relevant checks before accepting generated code.

A successful conversation proves neither application correctness nor safe unattended deployment.

**08 / PERSISTENCE AND DAY-TO-DAY OPERATION**

## Plan persistence and restart behaviour

Use a terminal multiplexer for an interactive session that should survive an SSH disconnect:

**Inside the VPS · Plan persistence and restart behaviour — Ubuntu · Bash**

```bash
tmux new -s claude-work
cd "$HOME/workspaces/claude-smoke-test"
claude
```

Detach using the multiplexer controls and reconnect with `tmux attach -t claude-work`. This preserves a terminal session, not a boot-time service or an automatically safe agent. A VPS reboot still requires the operating workflow you have chosen.

**09 / TROUBLESHOOTING**

## Troubleshoot without widening the risk

| Symptom | Controlled next check |
| --- | --- |
| Command not found | Check the installer result and PATH, then use `claude doctor`. |
| Login fails | Review the documented account/provider flow and outbound connectivity; do not post tokens in a support request. |
| Unexpected repository changes | Stop the task, inspect the diff and reduce permissions before retrying. |
| Session stops after a reboot | A terminal multiplexer is not a boot-time service; restart the intended interactive workflow. |

Stop when the observed result differs materially from the expected state. Collect a redacted error and environment record before choosing a different path.

**10 / UPDATES AND RECOVERY**

## Update and recover with matching state

Before an update, preserve the configuration and application state with a recovery method appropriate to that application. Stop or quiesce writes where consistency requires it. Keep the copy separate from the active server and protect the secrets it may contain.

Record the current binary or package version, runtime dependencies, configuration and service settings. Test the proposed change on a separate environment before changing production. An older executable may not understand a database or state file migrated by a newer version; rollback can require restoring the matching state, not just replacing the binary.

After recovery, repeat the provider, tool, access-control and restart checks. One platform backup and one snapshot are included with the VPS, but independent copies and the application-level restore process remain your responsibility.

**11 / RELATED RESOURCES**

## Related hosting and operating resources

[AI Agent VPS](<https://virtarix.com/solutions/ai-agent-hosting/>) · [AI self-hosting guides](<https://virtarix.com/docs/guides/ai/>) · [Infrastructure](<https://virtarix.com/infrastructure/>) · [Acceptable Use Policy](<https://virtarix.com/docs/legal/acceptable-use-policy/>)

## Claude Code questions

### Is a Claude subscription included?

No. You provide the appropriate account or provider access and pay any related charges separately.

### Should the agent run as root?

No. Use a limited application account and grant only the resources needed for the task.

### Does a persistent terminal make changes safe?

No. Review tool permissions, diffs and test results before accepting changes.

### Is this an official Virtarix integration?

This is a customer-operated workflow on a VPS, not an official SDK or a managed Claude Code service.
