AI Starter Package
Infrastructure

VPS Setup for AI Agents

Run your agents around the clock. A $5/month VPS gives you 24/7 availability, persistent sessions, and the ability to fire scheduled tasks at any hour.

Why Run Agents on a VPS?

24/7 availability

Scheduled tasks fire at 3 AM. Health checks run every 6 hours. Your laptop can sleep.

Persistent sessions

No context loss between sessions. Memory files persist. Logs accumulate over time.

Consistent environment

Same Node version, same paths, same API keys — no drift between developer machines.

Isolated resources

Long-running Claude tasks won't slow down your development machine or browser.

Recommended Providers

Any provider works. These three have the best balance of price, reliability, and developer experience.

Hetzner

~$5/mo
CX22: 2 vCPU, 4GB RAM, 40GB SSD

Best value, EU/US data centres

DigitalOcean

~$12/mo
Basic: 2 vCPU, 4GB RAM, 80GB SSD

Good docs, easy networking

Linode / Akamai

~$12/mo
Nanode 4GB: 2 vCPU, 4GB RAM, 80GB SSD

Reliable, global edge network

Minimum specs: 2 vCPU, 4GB RAM, 40GB SSD. Claude Code itself is lightweight; you need headroom for Node.js, npm caches, and any tools your agents call.

Initial Server Setup

After provisioning an Ubuntu 22.04 LTS server:

# 1. Connect and create a non-root user
ssh root@YOUR_SERVER_IP
adduser deploy
usermod -aG sudo deploy

# 2. Copy your SSH key to the new user
rsync --archive --chown=deploy:deploy ~/.ssh /home/deploy

# 3. Basic firewall
ufw allow 22/tcp
ufw allow 80/tcp
ufw allow 443/tcp
ufw --force enable

# 4. Install Node.js 20 via nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
source ~/.bashrc
nvm install 20
nvm use 20
node --version  # v20.x.x

Install Claude Code on VPS

# Install Claude Code globally
npm install -g @anthropic-ai/claude-code

# Set your API key (add to ~/.bashrc for persistence)
export ANTHROPIC_API_KEY="sk-ant-..."

# Verify the install
claude --version

# Clone your project and configure
git clone YOUR_REPO_URL ~/project
cd ~/project
claude --dangerously-skip-permissions /start
--dangerously-skip-permissions is required for headless/automated runs because there is no interactive terminal to approve tool calls. Only use it on dedicated agent machines — never on shared servers.

Running as a Background Service

systemdSystem-level service

# /etc/systemd/system/agent.service
[Unit]
Description=AI Agent
After=network.target

[Service]
User=deploy
WorkingDirectory=/home/deploy/project
ExecStart=/usr/bin/node /usr/local/bin/claude \
  --dangerously-skip-permissions /loop
Restart=on-failure
EnvironmentFile=/home/deploy/.env

[Install]
WantedBy=multi-user.target

# Enable and start
systemctl enable agent
systemctl start agent

pm2Process manager (easier)

# Install pm2
npm install -g pm2

# Start the agent loop
pm2 start "claude --dangerously-skip-permissions /loop" \
  --name agent \
  --cwd /home/deploy/project

# Auto-start on reboot
pm2 startup
pm2 save

# Monitor
pm2 logs agent
pm2 status

Security Hardening Basics

A VPS running an agent with your API keys is a target. Apply these before going live:

  • 1
    Disable root login over SSH — use a non-root sudo user
  • 2
    SSH key auth only — disable password authentication in sshd_config
  • 3
    UFW firewall: allow 22 (SSH), 80, 443 only
  • 4
    Install fail2ban to block brute-force attempts
  • 5
    Enable automatic security updates (unattended-upgrades)
  • 6
    Keep .env with API keys out of version control — use a secrets manager or env file with 600 permissions

Skip the Infrastructure Work

Hosted agent plans come with the VPS, setup, monitoring, and security all handled. You fill out an onboarding form — your agent is live within 48 hours.

View Pricing