# OpenClaw on a VPS: Complete Setup Guide

Canonical: https://clawdocx.com/docs/getting-started-vps
Author: Sam Okafor
Difficulty: BEGINNER
Published: 2026-02-24
Updated: 2026-02-25

> Deploy OpenClaw on any VPS provider, including DigitalOcean, Hetzner, Linode, Vultr, and AWS Lightsail, with a complete setup walkthrough.

## Why Run OpenClaw on a VPS?

A VPS (Virtual Private Server) gives you a dedicated, always-on machine in the cloud — perfect for running OpenClaw 24/7 without leaving your laptop open. It's the most popular way to host an OpenClaw agent.

> **Note**
>
> A $5-10/month VPS with 1 vCPU and 1-2 GB RAM is plenty for a single OpenClaw agent. You don't need a powerful machine — OpenClaw is lightweight.

### Choosing a Provider

| Provider | Cheapest Plan | Strengths | Best For |
|----------|--------------|-----------|----------|
| **Hetzner** | €3.79/mo (2 GB) | Best price-to-performance ratio | Budget-conscious users |
| **DigitalOcean** | $6/mo (1 GB) | Great docs, simple UI | Beginners |
| **Linode (Akamai)** | $5/mo (1 GB) | Solid performance, good support | Reliability |
| **Vultr** | $5/mo (1 GB) | Many locations, hourly billing | Flexibility |
| **AWS Lightsail** | $5/mo (1 GB) | AWS ecosystem integration | AWS users |
| **Oracle Cloud** | Free (24 GB ARM) | Always-free tier | See our [Oracle Cloud guide](/docs/getting-started-oracle-cloud) |

---

## Step 1: Create Your VPS

For this guide, we'll use a generic Ubuntu setup that works on any provider.

1. Sign up with your chosen provider
2. Create a new instance with:
   - **OS**: Ubuntu 24.04 LTS (or 22.04 LTS)
   - **Plan**: Cheapest available (1 vCPU, 1-2 GB RAM)
   - **Region**: Closest to you for lowest latency
   - **Authentication**: SSH key (strongly recommended over password)

### Setting Up SSH Keys (If You Haven't Already)

On your local machine:

```bash
# Generate an SSH key pair (if you don't have one)
ssh-keygen -t ed25519 -C "your-email@example.com"

# Copy the public key to your clipboard
# macOS:
cat ~/.ssh/id_ed25519.pub | pbcopy
# Linux:
cat ~/.ssh/id_ed25519.pub | xclip -selection clipboard
```

Paste this public key into your VPS provider's SSH key field during instance creation.

---

## Step 2: Connect to Your VPS

```bash
# Connect via SSH (replace with your VPS IP)
ssh root@YOUR_VPS_IP

# You should see a welcome message from Ubuntu
```

> **Warning**
>
> Running everything as root is fine for initial setup, but we'll create a dedicated user for OpenClaw in the next step.

### Create a Dedicated User

```bash
# Create a new user for OpenClaw
adduser openclaw

# Add to sudo group
usermod -aG sudo openclaw

# Copy SSH keys to new user
mkdir -p /home/openclaw/.ssh
cp ~/.ssh/authorized_keys /home/openclaw/.ssh/
chown -R openclaw:openclaw /home/openclaw/.ssh
chmod 700 /home/openclaw/.ssh
chmod 600 /home/openclaw/.ssh/authorized_keys

# Test login in a new terminal (don't close the root session yet!)
ssh openclaw@YOUR_VPS_IP
```

---

## Step 3: Secure Your VPS

```bash
# Update system packages
sudo apt update && sudo apt upgrade -y

# Install UFW firewall
sudo apt install ufw -y

# Allow SSH (important — don't lock yourself out!)
sudo ufw allow OpenSSH

# Enable firewall
sudo ufw enable

# Verify status
sudo ufw status
```

### Disable Root SSH Login

```bash
sudo nano /etc/ssh/sshd_config
```

Find and change:
```
PermitRootLogin no
PasswordAuthentication no
```

```bash
sudo systemctl restart sshd
```

---

## Step 4: Install Node.js

OpenClaw requires Node.js 20 or later.

```bash
# Install Node.js 22 LTS via NodeSource
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt-get install -y nodejs

# Verify installation
node --version   # Should show v22.x.x
npm --version    # Should show 10.x.x
```

> **Note**
>
> If you prefer nvm (Node Version Manager), that works too:
> ```bash
> curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
> source ~/.bashrc
> nvm install 22
> ```

---

## Step 5: Install OpenClaw

```bash
# Install OpenClaw globally
npm install -g openclaw

# Verify installation
openclaw --version

# Run the setup wizard
openclaw setup
```

The setup wizard will walk you through:
- Creating your workspace directory
- Setting up your first API key (Anthropic, OpenAI, etc.)
- Configuring your messaging channel (Telegram, Discord, etc.)
- Creating your SOUL.md

---

## Step 6: Configure as a systemd Service

This is the key step — systemd will keep OpenClaw running 24/7 and restart it automatically if it crashes.

```bash
# Create a systemd service file
sudo nano /etc/systemd/system/openclaw.service
```

Paste this configuration:

```ini
[Unit]
Description=OpenClaw AI Agent
After=network.target

[Service]
Type=simple
User=openclaw
WorkingDirectory=/home/openclaw/.openclaw/workspace
ExecStart=/usr/bin/openclaw gateway start --foreground
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
Environment=NODE_ENV=production

[Install]
WantedBy=multi-user.target
```

```bash
# Reload systemd and start
sudo systemctl daemon-reload
sudo systemctl enable openclaw   # Start on boot
sudo systemctl start openclaw    # Start now

# Check status
sudo systemctl status openclaw
```

### Viewing Logs

```bash
# Live logs
sudo journalctl -u openclaw -f

# Last 100 lines
sudo journalctl -u openclaw -n 100

# Logs since today
sudo journalctl -u openclaw --since today
```

---

## Step 7: Set Up Log Rotation

Prevent logs from filling your disk:

```bash
sudo nano /etc/logrotate.d/openclaw
```

```
/var/log/openclaw/*.log {
    daily
    missingok
    rotate 7
    compress
    delaycompress
    notifempty
}
```

---

## Step 8: Basic Monitoring

### Check If OpenClaw Is Running

```bash
# Quick status check
openclaw status

# Or via systemd
systemctl is-active openclaw
```

### Set Up a Simple Health Check

Add a cron job to alert you if OpenClaw goes down:

```bash
crontab -e
```

Add:
```
*/5 * * * * systemctl is-active openclaw || echo "OpenClaw is down!" | mail -s "Alert: OpenClaw Down" your@email.com
```

---

## Updating OpenClaw

```bash
# Stop the service
sudo systemctl stop openclaw

# Update
npm update -g openclaw

# Restart
sudo systemctl start openclaw

# Verify
openclaw --version
```

---

## Troubleshooting

### OpenClaw Won't Start
```bash
# Check logs for errors
sudo journalctl -u openclaw -n 50 --no-pager

# Common issues:
# - Missing API key → run openclaw setup
# - Port conflict → check with: ss -tlnp | grep 3000
# - Permission error → check file ownership
```

### SSH Connection Refused
```bash
# Check if SSH is running
sudo systemctl status sshd

# Check firewall
sudo ufw status

# Make sure port 22 is allowed
sudo ufw allow 22/tcp
```

### High Memory Usage
```bash
# Check memory
free -h

# If needed, add swap
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
```

---

## Next Steps

- [Your First 24 Hours with OpenClaw](/docs/first-24-hours) — Set up SOUL.md, connect Telegram, install your first skill
- [Security Hardening Guide](/docs/security-hardening) — Lock down your VPS and agent
- [Process Management Guide](/docs/process-management) — Advanced systemd, pm2, and monitoring
- [Cost Optimization](/docs/cost-optimization) — Keep API bills under control