Run OpenClaw Safely on a VPS: Setup and Hardening
OpenClaw can read chat messages, run tools, and control a browser. That makes it useful, but a careless VPS setup can expose its gateway, credentials, and the services it can reach. This guide keeps the agent isolated and its control panel private.
OpenClaw is an open-source AI agent that can read messages, run shell commands, and interact with websites. Those abilities make it useful—and give a misconfigured installation a lot of reach. If you install it on a server and expose its control gateway to the public internet, you may expose a route to the agent and the credentials it can use.
The scale is not hypothetical: Censys counted 21,639 internet-reachable OpenClaw instances on 31 January 2026. A reachable instance is not proof of compromise, but it is a reason to check what your own server exposes. The project has also used the names Clawdbot and Moltbot; include all three when searching historical logs or advisories.
Choose an isolated host
A dedicated KVM VPS gives the agent a separate virtual machine, operating system, and kernel from your other services. Keep it separate from a WordPress site, customer database, or other sensitive workload: if the agent or one of its tools is compromised, isolation limits what else is immediately within reach.
OpenClaw’s hosting FAQ lists 1 vCPU and 1 GB RAM as the absolute minimum and recommends 1–2 vCPU and at least 2 GB RAM for headroom. Browser automation and media tools can use more. Start with a current Ubuntu LTS or another modern Debian/Ubuntu image, and size the server for the tools you plan to enable. KVM VPS provides an isolated virtual server with root access; check the current plan specifications before choosing a size.
Secure SSH and the firewall first
Start from a fresh operating-system image. Create a named administrator account, add your SSH public key, and confirm that a second SSH session works before closing the original. Only then disable root and password login in your SSH configuration. Keep a recovery route available through your provider’s console or rescue environment before changing network access.
Set the host firewall to deny unsolicited inbound traffic and allow only the access you need, usually SSH. OpenClaw’s Gateway uses port 18789 by default. Do not expose that port publicly. If you use Tailscale, join the server and verify access through its private address before restricting public SSH.
Run OpenClaw as an unprivileged user
Create a separate operating-system user for OpenClaw and do not give the agent account routine sudo access. Use your administrator account for system changes, then switch to the OpenClaw account for onboarding:
openclaw onboard --install-daemonIf a global npm install fails because of permissions, use a user-level npm prefix or a version manager. Granting the agent sudo to get past an install error expands the damage it can do.
A systemd user service may stop when the user has no active login session. Check whether lingering is enabled:
loginctl show-user openclaw | grep LingerIf it reports Linger=no, an administrator can enable it with sudo loginctl enable-linger openclaw. Use the exact service setup documented for your OpenClaw version.
Keep the Gateway private
For a regular host installation, the current OpenClaw documentation says the Gateway defaults to loopback. Verify the effective setting rather than relying on a default:
openclaw config get gateway.bindSet it to loopback if necessary:
openclaw config set gateway.bind loopbackKeep the Gateway authentication token enabled. Generate a long random token if you need to replace it; the project’s security audit flags weak tokens. A local-only listener reduces exposure, but it is not a substitute for updates and browser security. CVE-2026-25253 described token theft through a crafted gateway URL in affected versions; the issue was fixed in OpenClaw 2026.1.29. Run a current supported release.
Docker needs an extra network check
Do not assume the host-install default also applies inside a container. OpenClaw’s Gateway configuration guide says a container with no explicit bind setting can use auto, which resolves to all interfaces so published ports work. Bind the host side of the port to loopback, for example:
127.0.0.1:18789:18789Docker-published ports can bypass ordinary UFW input rules. If you need network-level filtering for container traffic, follow Docker’s firewall guidance and use the appropriate Docker forwarding chain, such as DOCKER-USER. Then scan from a machine outside the VPS to confirm that the Gateway is not reachable. Do not assume the network interface is named eth0; VPS images commonly use other names.
Connect through Tailscale or an SSH tunnel
For a single-user agent, keep the Gateway on loopback and connect through a private overlay network or SSH tunnel. The OpenClaw project documents Tailscale Serve as a way to reach the Gateway without binding it to a public interface. If you prefer SSH, forward the local port from your computer:
ssh -L 18789:127.0.0.1:18789 user@your-vpsThen open the dashboard at http://127.0.0.1:18789 on your computer. Avoid a public reverse proxy unless you specifically need one and can configure authentication, trusted proxy headers, and network restrictions correctly.
Run the security audit after changes
OpenClaw provides a built-in configuration and permissions audit. Run it after installation, after significant configuration changes, and after updates:
openclaw security auditThe deeper mode adds checks against the running Gateway and scans installed plugin or skill code:
openclaw security audit --deepReview the findings; an audit is a useful check, not a penetration test or proof that the agent is safe.
Limit channels, skills, and credentials
Every connected account, skill, and tool increases what the agent can access. Begin with only the channels and capabilities you need. Restrict chat access with allowlists. For Telegram, OpenClaw expects numeric user IDs in allowFrom; a username is not a substitute. Its Telegram access-control guide explains the current configuration.
Install skills only from sources you can inspect, and review their code before granting access to files, shell commands, or credentials. Keep secrets out of prompts and general workspace files. Rotate API tokens if they may have been exposed. Require human approval for actions that are difficult to undo, such as payments, deletions, or messages sent outside your organization.
Singapore’s Cyber Security Agency lists unpatched flaws, weak access controls, sensitive-data exposure, malicious third-party skills, and memory poisoning among the risks in its OpenClaw advisory. Its recommendations include least privilege, trusted skills, regular token rotation, and human approval for consequential actions. The advisory addresses autonomous agents, not VPS hosting generally.
Back up state and keep logs
OpenClaw stores configuration, credentials, and workspace data under ~/.openclaw by default. Back up the state you need to recover, restrict access to those backups, and encrypt copies that leave the server. Test a restore instead of assuming a backup is usable. Store logs somewhere persistent with permissions that prevent unrelated users from reading them; temporary directories may be cleared during a reboot.
Keep OpenClaw and its runtime current. Read release notes before updating, apply security releases promptly, and rerun the audit afterward. Do not copy old commands or configuration blindly: defaults and supported settings can change between releases.
Keep the agent away from production data
Installing OpenClaw beside a public website may seem convenient, but it puts both services in the same failure zone. A compromised agent may be able to reach files, sockets, or local services belonging to the other application. Give the agent its own small KVM VPS, connect only the accounts it needs, and avoid giving it access to a live customer database.
Before you call the setup finished, confirm that SSH works with your intended access method, the Gateway is not reachable from the public internet, the agent runs without routine root privileges, backups can be restored, and openclaw security audit --deep has no unexplained findings. That routine is less exciting than a one-command install. It also keeps a capable agent from becoming an avoidable entry point.