Production-ready Terraform infrastructure for deploying OpenClaw with security hardening built-in
Features β’ Quick Start β’ Documentation β’ Contributing β’ Security
Deploy OpenClaw on DigitalOcean with a production-focused baseline that includes infrastructure automation, security hardening, and operational best practices out of the box.
Why use this?
- π Fast deployment - Single command to provision and configure everything
- π Secure by default - SSH-only access, firewall rules, fail2ban, automatic updates
- π― Production-ready - Loopback-only gateway with SSH tunnel access
- β CI/CD integrated - Automated validation with Terraform, tflint, and checkov
- π¦ CloudDrove powered - Using battle-tested reusable GitHub Actions workflows
- Terraform >= 1.5.4
- DigitalOcean account and API token
- SSH key added to DigitalOcean
# Set your DigitalOcean token
export DIGITALOCEAN_TOKEN="your_token_here"
# Copy and edit configuration
cp infra/env/prod.tfvars.example infra/env/prod.tfvars
# Edit prod.tfvars with your SSH key fingerprint and preferencesOptional but recommended: Configure remote state storage
cp infra/backend.tf.example infra/backend.tf
# Edit backend.tf with your state backend settingsmake upThis command will:
- Create a VPC and networking resources
- Provision a hardened Droplet
- Install and configure OpenClaw
- Set up security rules and monitoring
Connect via SSH tunnel for secure access:
ssh -p 1389 -N -L 18789:127.0.0.1:18789 ubuntu@<droplet-ip>Then open http://127.0.0.1:18789 in your browser.
βββββββββββββββββββββββββββββββββββββββ
β DigitalOcean VPC (10.10.0.0/16) β
β β
β ββββββββββββββββββββββββββββββββ β
β β Hardened Ubuntu Droplet β β
β β β β
β β β’ OpenClaw (127.0.0.1:18789)β β
β β β’ UFW Firewall (SSH only) β β
β β β’ fail2ban β β
β β β’ Auto-updates β β
β ββββββββββ¬ββββββββββββββββββββββ β
β β β
βββββββββββββΌββββββββββββββββββββββββββ
β
β SSH Tunnel (Port 1389)
β
[Your Machine]
Key design decisions:
- OpenClaw gateway binds to localhost only (no public exposure)
- All access goes through SSH tunnel
- Firewall allows only SSH traffic
- SSH uses key-based auth only, root login disabled
See docs/architecture.md for detailed diagrams.
βββ infra/ Terraform infrastructure code
β βββ main.tf Main infrastructure definitions
β βββ variables.tf Input variables
β βββ outputs.tf Output values
β βββ env/ Environment configurations
βββ scripts/ All operational scripts
β βββ bootstrap.sh System hardening and OpenClaw setup
β βββ post-install-checks.sh Verify deployment
β βββ security-audit.sh Security validation
β βββ ssh-tunnel.sh Tunnel helper
βββ docs/ Documentation
β βββ architecture.md
β βββ PROD_READINESS_CHECKLIST.md
βββ .github/workflows/ CI/CD automation
After deployment, run these checks to verify everything is configured correctly:
# Verify OpenClaw is running and healthy
./scripts/post-install-checks.sh
# Run security audit
./scripts/security-audit.shExpected results:
- β
OpenClaw gateway bound to
127.0.0.1:18789 - β Firewall allows only SSH (port 1389)
- β
openclaw doctor --non-interactivepasses - β
openclaw security audit --deepshows no critical issues
This baseline includes multiple layers of security hardening:
Network Security
- Loopback-only OpenClaw gateway (no direct internet access)
- UFW firewall with deny-by-default policy
- SSH rate limiting to prevent brute force attacks
SSH Hardening
- Key-based authentication only (passwords disabled)
- Root login disabled
- Non-standard SSH port (1389)
- fail2ban monitoring for intrusion attempts
System Hardening
- Unattended security updates enabled
- Minimal attack surface (only required packages)
- Regular security patching workflow
Important: This configuration provides a strong security baseline, but security is an ongoing process. Regularly update, audit, and monitor your deployment.
make planSSH into the server and follow OpenClaw's update procedure:
ssh -p 1389 ubuntu@<droplet-ip>
# Follow OpenClaw update instructionscd infra && terraform showmake down| Issue | Cause | Solution |
|---|---|---|
| Cannot connect to dashboard | SSH tunnel not running | Re-run the SSH tunnel command and keep terminal open |
ERR_CONNECTION_REFUSED |
Wrong port or OpenClaw not running | Check OpenClaw status: systemctl status openclaw |
| Terraform validation fails | Variable type mismatch | Review infra/variables.tf and your .tfvars file |
| SSH connection refused | Wrong IP or firewall issue | Verify droplet IP with terraform output |
For more help, check docs/PROD_READINESS_CHECKLIST.md.
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
When submitting PRs, include:
- Description of changes
- Reasoning and use case
- Risk assessment
- Testing/verification steps
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
We take security seriously. See SECURITY.md for our security policy and how to report vulnerabilities.
See CHANGELOG.md for detailed version history.
β If you find this helpful, please star the repo!
Made with β€οΈ for the OpenClaw community