Setting Up OpenClaw on Tailscale and Hetzner
In this guide, I'll walk you through how I deployed OpenClaw — my personal AI assistant — on a Hetzner VPS, secured with Tailscale for private access, and hardened the server for production use.
Why This Setup?
- Hetzner: Affordable, reliable VPS hosting in Europe (€4.51/month for 2 vCPU/4GB)
- Tailscale: Zero-config VPN for secure access without exposing ports to the internet
- OpenClaw: AI assistant that helps with coding, research, and daily tasks
- Security First: SSH hardening, fail2ban, and firewall rules from day one
Prerequisites
- Hetzner Cloud account
- Tailscale account
- SSH key pair (no password auth!)
- Basic Linux knowledge
Step 1: Provision the VPS
-
Log into Hetzner Cloud Console
-
Create a new project
-
Deploy a server:
- Location: Falkenstein (EU) or Ashburn (US)
- Type: CX21 (2 vCPU, 4GB RAM, 40GB disk)
- Image: Ubuntu 22.04 LTS
- SSH Key: Add your public key (no passwords!)
- Name:
openclaw-server
-
Note the public IP — we'll use it once, then lock it down
Step 2: Initial Server Hardening
SSH in and immediately secure the server:
ssh root@<your-server-ip>
# 1. Update systemapt update && apt upgrade -y
# 2. Create a non-root useradduser clawusermod -aG sudo claw
# 3. Copy SSH key to new usermkdir -p /home/claw/.sshcp ~/.ssh/authorized_keys /home/claw/.ssh/chown -R claw:claw /home/claw/.sshchmod 700 /home/claw/.sshchmod 600 /home/claw/.ssh/authorized_keys
# 4. Install and configure fail2banapt install -y fail2ban
cat > /etc/fail2ban/jail.local << 'EOF'[DEFAULT]bantime = 1hfindtime = 10mmaxretry = 3
[sshd]enabled = trueport = sshfilter = sshdlogpath = /var/log/auth.logmaxretry = 3bantime = 24hEOF
systemctl enable fail2bansystemctl start fail2ban
# 5. Configure UFW firewallapt install -y ufwufw default deny incomingufw default allow outgoingufw allow sshufw --force enable
# 6. Harden SSH configcat >> /etc/ssh/sshd_config << 'EOF'
# Security hardeningPermitRootLogin noPasswordAuthentication noPubkeyAuthentication yesX11Forwarding noMaxAuthTries 3ClientAliveInterval 300ClientAliveCountMax 2EOF
systemctl restart sshdExit and reconnect as the new user:
exitssh claw@<your-server-ip>Step 3: Install Tailscale
# Install Tailscalecurl -fsSL https://tailscale.com/install.sh | sh
# Start and authenticatesudo tailscale upYou'll get an authentication link. Open it in your browser and sign in. Once done:
# Get your Tailscale IPtailscale ip -4# → 100.x.x.x (save this!)Lock down SSH to Tailscale only
sudo nano /etc/ssh/sshd_configChange ListenAddress to only listen on Tailscale:
# Comment out: ListenAddress 0.0.0.0# Add: ListenAddress 100.x.x.x (your Tailscale IP)Also update firewall:
# Remove public SSH accesssudo ufw delete allow ssh# Allow Tailscale interface onlysudo ufw allow in on tailscale0 to any port 22sudo systemctl restart sshdFrom now on, only connect via Tailscale:
ssh claw@100.x.x.xStep 4: Install OpenClaw
OpenClaw provides official packages. Don't clone from git — use the proper install:
# Install OpenClaw (follow official docs for your OS)# For Ubuntu/Debian:curl -fsSL https://openclaw.ai/install.sh | bash
# Or download directly from releases:# https://github.com/openclaw/openclaw/releases
# Verify installationopenclaw --versionRun the Onboarding Wizard
# Start the interactive setupopenclaw onboardThe wizard will guide you through:
- Gateway mode: Local (loopback) or remote
- Workspace: Where your agent files live
- Channels: Telegram, WhatsApp, Discord, etc.
- Providers: OpenAI, Anthropic, or custom endpoints
- Web search: Perplexity, Brave, etc.
- Skills: Enable/disable agent skills
Quick tip: The fastest way to start chatting is the dashboard — no channel setup needed!
openclaw dashboardFor detailed wizard options, see:
Step 5: Configure for Tailscale Access
After onboarding, configure OpenClaw to work with your Tailscale network:
# Edit configurationopenclaw configureKey settings for Tailscale:
- Gateway bind: Set to your Tailscale IP (100.x.x.x)
- Tailscale exposure: Enable if you want to advertise the service
- Auth token: Generate a strong token for API access
Step 6: Start the Gateway
# Start the OpenClaw daemonopenclaw gateway start
# Check statusopenclaw status
# View logsjournalctl -u openclaw -fStep 7: Connect Your Clients
From your local machine (with Tailscale)
# Configure to use remote gatewayopenclaw configure --gateway https://100.x.x.x:18789
# Test connectionopenclaw pingTelegram Bot
- Create a bot with @BotFather
- Set the webhook:
curl -F "url=https://100.x.x.x:18789/webhook" \ https://api.telegram.org/bot<YOUR_BOT_TOKEN>/setWebhookVS Code Extension
Install the OpenClaw extension and configure:
- Gateway URL:
https://100.x.x.x:18789 - Auth token: (from your config)
Security Benefits of This Setup
| Layer | Protection |
|---|---|
| Fail2ban | Auto-bans IPs with failed SSH attempts |
| UFW | Firewall blocks all non-essential ports |
| SSH hardening | No root, no passwords, key-only auth |
| Tailscale | Private mesh network, no public exposure |
| WireGuard | Encrypted traffic between all devices |
Monitoring & Maintenance
Check fail2ban status
sudo fail2ban-client status sshdsudo fail2ban-client statusView blocked IPs
sudo zgrep "Ban" /var/log/fail2ban.logUpdate OpenClaw
openclaw update# oropenclaw self-updateBackup your workspace
tar -czf openclaw-backup-$(date +%Y%m%d).tar.gz ~/.openclaw/Troubleshooting
Tailscale not connecting?
sudo tailscale statussudo tailscale up --force-reauthOpenClaw gateway won't start?
# Check logsjournalctl -u openclaw -n 100 --no-pager
# Check config is validopenclaw config validateCan't SSH after hardening?
Make sure you're connecting from a device on your Tailscale network:
# From a device WITH Tailscalessh claw@100.x.x.x
# Test Tailscale connectionping 100.x.x.xCost Breakdown
| Service | Monthly Cost |
|---|---|
| Hetzner CX21 | €4.51 |
| Tailscale (free tier, 1 user) | €0 |
| Total | €4.51 |
Conclusion
You now have a production-hardened OpenClaw deployment:
- ✅ Server secured with fail2ban + UFW + SSH hardening
- ✅ Private network via Tailscale (no public exposure)
- ✅ AI assistant ready to help with coding, research, and automation
- ✅ Accessible from all your devices securely
This setup gives you enterprise-grade security for under €5/month. The combination of Hetzner's affordable VPS, Tailscale's zero-config VPN, and OpenClaw's powerful AI assistant is perfect for personal infrastructure.
Resources
Questions? Hit me up on Twitter.