OpenClaw on a VPS: Complete Setup Guide
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.
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 |
#Step 1: Create Your VPS
For this guide, we'll use a generic Ubuntu setup that works on any provider.
- Sign up with your chosen provider
- 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:
# 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 clipboardPaste this public key into your VPS provider's SSH key field during instance creation.
#Step 2: Connect to Your VPS
# Connect via SSH (replace with your VPS IP)ssh root@YOUR_VPS_IP# You should see a welcome message from UbuntuRunning 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
# Create a new user for OpenClawadduser openclaw# Add to sudo groupusermod -aG sudo openclaw# Copy SSH keys to new usermkdir -p /home/openclaw/.sshcp ~/.ssh/authorized_keys /home/openclaw/.ssh/chown -R openclaw:openclaw /home/openclaw/.sshchmod 700 /home/openclaw/.sshchmod 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
# Update system packagessudo apt update && sudo apt upgrade -y# Install UFW firewallsudo apt install ufw -y# Allow SSH (important — don't lock yourself out!)sudo ufw allow OpenSSH# Enable firewallsudo ufw enable# Verify statussudo ufw status#Disable Root SSH Login
sudo nano /etc/ssh/sshd_configFind and change:
PermitRootLogin noPasswordAuthentication nosudo systemctl restart sshd#Step 4: Install Node.js
OpenClaw requires Node.js 20 or later.
# Install Node.js 22 LTS via NodeSourcecurl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -sudo apt-get install -y nodejs# Verify installationnode --version # Should show v22.x.xnpm --version # Should show 10.x.xIf you prefer nvm (Node Version Manager), that works too:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bashsource ~/.bashrcnvm install 22#Step 5: Install OpenClaw
# Install OpenClaw globallynpm install -g openclaw# Verify installationopenclaw --version# Run the setup wizardopenclaw setupThe 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.
# Create a systemd service filesudo nano /etc/systemd/system/openclaw.servicePaste this configuration:
[Unit]Description=OpenClaw AI AgentAfter=network.target[Service]Type=simpleUser=openclawWorkingDirectory=/home/openclaw/.openclaw/workspaceExecStart=/usr/bin/openclaw gateway start --foregroundRestart=alwaysRestartSec=10StandardOutput=journalStandardError=journalEnvironment=NODE_ENV=production[Install]WantedBy=multi-user.target# Reload systemd and startsudo systemctl daemon-reloadsudo systemctl enable openclaw # Start on bootsudo systemctl start openclaw # Start now# Check statussudo systemctl status openclaw#Viewing Logs
# Live logssudo journalctl -u openclaw -f# Last 100 linessudo journalctl -u openclaw -n 100# Logs since todaysudo journalctl -u openclaw --since today#Step 7: Set Up Log Rotation
Prevent logs from filling your disk:
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
# Quick status checkopenclaw status# Or via systemdsystemctl is-active openclaw#Set Up a Simple Health Check
Add a cron job to alert you if OpenClaw goes down:
crontab -eAdd:
*/5 * * * * systemctl is-active openclaw || echo "OpenClaw is down!" | mail -s "Alert: OpenClaw Down" your@email.com#Updating OpenClaw
# Stop the servicesudo systemctl stop openclaw# Updatenpm update -g openclaw# Restartsudo systemctl start openclaw# Verifyopenclaw --version#Troubleshooting
#OpenClaw Won't Start
# Check logs for errorssudo 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
# Check if SSH is runningsudo systemctl status sshd# Check firewallsudo ufw status# Make sure port 22 is allowedsudo ufw allow 22/tcp#High Memory Usage
# Check memoryfree -h# If needed, add swapsudo fallocate -l 2G /swapfilesudo chmod 600 /swapfilesudo mkswap /swapfilesudo swapon /swapfileecho '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab#Next Steps
- Your First 24 Hours with OpenClaw — Set up SOUL.md, connect Telegram, install your first skill
- Security Hardening Guide — Lock down your VPS and agent
- Process Management Guide — Advanced systemd, pm2, and monitoring
- Cost Optimization — Keep API bills under control