The Security-First Setup pattern deploys OpenClaw on a Hetzner CX23 VPS, locked down with UFW firewall rules, SSH key-only access, and a Tailscale VPN before OpenClaw is installed, so the agent has zero public ports. Setup takes 90 minutes and runs under $20 a month, including a Telegram-connected default agent.
What you will be able to do
- Provision a Hetzner CX23 VPS and lock it down with SSH key-only access and a deny-by-default UFW firewall
- Put the VPS and your laptop on the same private Tailscale network so no OpenClaw port is ever exposed to the public internet
- Set up burner Gmail and Telegram accounts so the agent never touches your real inbox or messages
- Install Docker and run the OpenClaw setup wizard to get a default agent responding to Telegram messages
- Open the OpenClaw dashboard through an SSH tunnel over Tailscale instead of a public URL
Before you start
- Laptop with terminal access (macOS, Linux, or WSL on Windows)
- Credit card for Hetzner (about $4 a month for the VPS)
- Comfort typing terminal commands (no need to understand them)
- About 90 minutes of focused time, plan for up to 2 hours on a first server setup
Reference
| Step | Command / Setting | Purpose |
|---|---|---|
| Generate SSH key | ssh-keygen -t ed25519 -C "openclaw-hetzner" |
Creates the key used for VPS login |
| Cache SSH key | ssh-add ~/.ssh/id_ed25519 |
Avoids retyping the passphrase every SSH command |
| Deny-by-default firewall | ufw default deny incoming, ufw default allow outgoing, ufw allow ssh, ufw enable |
Closes every port except SSH before OpenClaw touches the system |
| Disable password login | Edit /etc/ssh/sshd_config, set PasswordAuthentication no, then systemctl restart ssh |
Requires key-based login, stops brute-force SSH attempts |
| Install and start Tailscale | curl -fsSL https://tailscale.com/install.sh | sh then tailscale up |
Puts the VPS on a private 100.x.x.x network only your devices can reach |
| Allow Tailscale subnet in UFW | ufw allow from 100.64.0.0/10 |
Lets your Tailscale devices reach the VPS while public traffic stays blocked |
| VPS spec | Hetzner CX23: 4GB RAM, 2 vCPU, 40GB SSD, Ubuntu 24.04 LTS | Enough headroom for OpenClaw plus Docker overhead, about $5 a month with IPv4 |
| Gmail app password | Go directly to myaccount.google.com/apppasswords |
Lets OpenClaw connect to the burner Gmail via IMAP without the real account password |
Common errors and fixes
| What goes wrong | The fix |
|---|---|
*** System restart required *** appears after apt update && apt upgrade -y |
Run reboot, wait 30 seconds, then reconnect with ssh root@[YOUR-VPS-IP] |
| SSH connection returns "Permission denied" | Check you used the correct VPS IP and that your public key was actually added in Hetzner's SSH Keys field |
| First SSH connection shows "The authenticity of host can't be established" | This is normal on a first connection, type yes to continue |
| Connecting a real Gmail account directly to the agent risks data loss (a reported case had 200+ emails deleted when an agent lost context mid-thread) | Use burner Gmail and Telegram accounts instead of primary accounts, so a mistake only costs burner data |
| Following the common "get it working first, secure it later" setup order leaves the instance exposed, as with the 42,665 scanned OpenClaw instances (93.4% had authentication bypasses) | Do Tailscale, the firewall, and burner accounts before installing OpenClaw, not after |
Read the full walkthrough
The complete lesson, with screenshots and any downloads, is published on Substack as part of OpenClaw for Solopreneurs: AI Agents That Work While You Sleep.
Continue the course
Browse all lessons in the OpenClaw for Solopreneurs: AI Agents That Work While You Sleep course, or subscribe to the GenAI Unplugged newsletter to get new lessons in your inbox.