# From your local machine:
scp -r openclaw-deploy/ user@server:~/openclaw-deploy/
# On the server:
ssh user@server
cd ~/openclaw-deploy
cp .env.example .env
nano .env # Fill in OPENCLAW_GATEWAY_PASSWORD and TELEGRAM_BOT_TOKEN
sudo bash install_and_harden.sh| Variable | Description | How to generate |
|---|---|---|
OPENCLAW_GATEWAY_PASSWORD |
Password for gateway authentication | openssl rand -base64 32 |
TELEGRAM_BOT_TOKEN |
Bot API token from Telegram | Message @BotFather on Telegram |
-
Authenticate Tailscale (interactive — cannot be scripted):
sudo tailscale up
-
Enable Tailscale Serve — re-run the installer after authenticating:
sudo bash ~/openclaw-deploy/install_and_harden.shOr manually:
sudo tailscale serve --bg --https=443 http://127.0.0.1:18789
-
OAuth setup — run
openclaw authvia SSH tunnel:# From your local machine (forward port 18789): ssh -L 18789:127.0.0.1:18789 user@server # Then open http://localhost:18789 in your browser to complete OAuth
Telegram Bot API
│
▼
┌──────────────────┐
│ OpenClaw Gateway │ ← bound to 127.0.0.1:18789 (loopback only)
│ (Docker, non-root)│
└──────┬───────────┘
│
▼
Tailscale Serve (HTTPS :443)
│
▼
Tailnet devices only (not public internet)
Defense in depth:
- Network: loopback bind + UFW default-deny + Tailscale Serve (not Funnel)
- Auth: gateway password + Tailscale identity + Telegram DM pairing
- Process: non-root
openclawuser + Docker non-root + agent sandbox (non-main) - Monitoring: Fail2ban (SSH) +
openclaw doctor+openclaw security audit - Patching: unattended-upgrades (security updates daily)
cd /home/openclaw
sudo -u openclaw docker compose pull
sudo -u openclaw docker compose up -d# Docker logs
sudo -u openclaw docker compose -f /home/openclaw/docker-compose.yml logs -f gateway
# Application logs
tail -f /var/log/openclaw/*.logsudo -u openclaw openclaw doctor --non-interactive
sudo -u openclaw openclaw security audit --deepcd /home/openclaw
sudo -u openclaw docker compose restart gatewayEach step is independent. Run only what you need. Destructive steps are marked.
-
Stop and remove containers:
cd /home/openclaw && sudo -u openclaw docker compose down
-
Remove Tailscale Serve:
sudo tailscale serve --remove --https=443
-
⚠️ Delete OpenClaw data (irreversible):sudo rm -rf /home/openclaw/.openclaw sudo rm -rf /var/log/openclaw
-
Remove openclaw user:
sudo userdel -r openclaw
-
Remove UFW rules:
sudo ufw delete deny 18789/tcp sudo ufw delete allow in on tailscale0 -
Remove Fail2ban config:
sudo rm /etc/fail2ban/jail.local sudo systemctl restart fail2ban
-
Remove logrotate config:
sudo rm /etc/logrotate.d/openclaw
-
⚠️ Uninstall Tailscale (removes from tailnet):sudo tailscale down sudo apt-get purge -y tailscale
-
⚠️ Uninstall Docker (affects all containers):sudo apt-get purge -y docker-ce docker-ce-cli containerd.io \ docker-buildx-plugin docker-compose-plugin
-
Remove deployment files:
rm -rf ~/openclaw-deploy