export VPSSecurityGuide
/** Lock down your OpenClaw VPS with 5 layers of security - $6/month */

π¨## The Problem: Exposed AI Instances
When you deploy OpenClaw on a VPS using the default configuration, you're essentially leaving your front door wide open. The Docker container exposes ports directly to the internet, there's no authentication required to access your dashboard, and your API keys are just one port scan away from being compromised.
Security researchers have already discovered over 900 OpenClaw instances running completely unprotected on the public internet. These exposed instances are vulnerable to API key theft, unauthorized usage (running up your AI provider bills), data exfiltration, and being used as pivot points for further attacks.
## π‘οΈ The 5 Layers of Security
This guide implements a defense-in-depth strategy with five distinct security layers. Each layer provides protection against different attack vectors, and together they create a robust security posture that makes your OpenClaw instance essentially invisible to the public internet.
## π Layer 1: Tailscale Private Network
Tailscale creates a secure, private network using WireGuard encryption. It's free for personal use (up to 100 devices) and takes just minutes to set up. Once configured, your VPS will only be accessible from devices on your Tailscale network.
Step 1: Install Tailscale on Your VPS
Step 2: Authenticate Tailscale
This will output a URL. Open it in your browser to authorize the device with your Tailscale account.
Step 3: Find Your Bot's Port
Note the port number (typically 18789). You'll need this for the next steps.
Step 4: Configure Tailscale Serve
This creates a secure HTTPS endpoint accessible only through your Tailscale network.
## π§± Layer 2: UFW Firewall Configuration
UFW (Uncomplicated Firewall) provides a simple way to manage iptables rules. We'll configure it to block the OpenClaw port from the public internet while allowing access through the Tailscale interface.
Step 6: Configure Firewall Rules
// β οΈ IMPORTANT: Always allow SSH before enabling the firewall, or you'll lock yourself out!
Step 7: Verify Port is Hidden
## π Layer 3: Token Authentication
OpenClaw includes a built-in gateway token for authentication. This adds another layer of security - even if someone gains access to your Tailscale network, they still need the token to access the dashboard.
Step 8: Get Your Gateway Token
Step 9: Access Secured Dashboard
// π‘ Pro tip: Bookmark this URL with the token for quick access from your authorized devices.
## π« Layer 4: Fail2ban Brute-Force Protection
Fail2ban monitors log files for failed authentication attempts and automatically bans offending IP addresses. This protects your SSH access from brute-force attacks where hackers try thousands of password combinations.
Step 10: Install and Enable Fail2ban
## π Layer 5: Automatic Security Updates
Keeping your server updated is crucial for security. Unattended-upgrades automatically installs security patches without manual intervention, ensuring zero-day vulnerabilities get patched as soon as fixes are available.
Step 11: Enable Auto Updates
## π± Bonus: Telegram Control
For ultimate convenience, configure Telegram as a control channel for your OpenClaw instance. This allows you to interact with your AI assistant from anywhere without needing to access the web dashboard.
Step 12: Telegram Bot Setup
## β Verification Checklist
Use this checklist to verify all security layers are properly configured:
## π° Cost Breakdown
| Service | Cost | Notes |
|---|---|---|
| VPS (DigitalOcean/Hetzner) | $6/month | 1GB RAM, 1 vCPU |
| Tailscale | Free | Up to 100 devices |
| UFW Firewall | Free | Built into Ubuntu |
| Fail2ban | Free | Open source |
| Total | $6/month | Full security stack |
π For just $6/month, your OpenClaw instance is now invisible to the public internet, protected by 5 security layers, and running 24/7 on a dedicated VPS!
## π₯ Video Walkthrough
Prefer video? Watch the complete step-by-step walkthrough:
βΆWatch on YouTube## π Next Steps
Your OpenClaw instance is now secured! Explore these related tutorials: