On this page

On this page

Hosting

Ansible

Deploy OpenClaw to production servers with openclaw-ansible, an automated installer with a security-first architecture.

Prerequisites

Requirement Details
OS Debian 11+ or Ubuntu 20.04+
Access Root or sudo privileges
Network Internet connection for package installation
Ansible 2.14+ (installed automatically by the quick-start script)

What you get

  • Firewall-first security: UFW + Docker isolation (only SSH reachable, plus Tailscale when enabled)
  • Optional Tailscale VPN for remote access without exposing services publicly
  • Docker for isolated sandbox containers with localhost-only bindings
  • A dedicated unprivileged openclaw user with scoped sudo, ready for openclaw onboard --install-daemon
  • One-command setup

Quick start

bash
curl -fsSL https://raw.githubusercontent.com/openclaw/openclaw-ansible/main/install.sh | bash

What gets installed

  1. Tailscale (mesh VPN), only when tailscale_enabled=true
  2. UFW firewall (SSH only, plus Tailscale when enabled), fail2ban for SSH, and unattended security upgrades
  3. Docker CE + Compose V2 (default agent sandbox backend)
  4. Node.js from NodeSource (major version set by nodejs_version) and pnpm. OpenClaw accepts Node 24.16.0+ on 24.x or 26.1.0+; 24.22.1+/26.12.1+ is strongly recommended for security. Check node --version after the install.
  5. OpenClaw, installed host-based with pnpm as the openclaw user, not containerized

The playbook does not create openclaw.json or a Gateway service. Onboarding does both: it installs the Gateway as the systemd user service openclaw-gateway.service of the openclaw user. The installer does not add systemd sandboxing directives (such as NoNewPrivileges or PrivateTmp) to that unit.

Post-install setup

  • Switch to the openclaw user

    bash
    sudo -i -u openclaw
  • Run onboarding and install the Gateway service

    bash
    openclaw onboard --install-daemon
  • Connect messaging channels

    Log in to WhatsApp, Telegram, Discord, or Signal:

    bash
    openclaw channels login --channel <name>
  • Verify the installation

    bash
    openclaw gateway statusopenclaw security audit
  • Connect to Tailscale (optional)

    If you installed with tailscale_enabled=true, join your VPN mesh for secure remote access.

  • Quick commands

    Run these as the openclaw user (sudo -i -u openclaw):

    bash
    # Check service statusopenclaw gateway statussystemctl --user status openclaw-gateway.service # View live logsopenclaw logs --follow # Restart gatewayopenclaw gateway restart # Channel loginopenclaw channels login --channel <name>

    openclaw gateway restart records managed restart intent. For a system-scope service, follow the exact sudo systemctl restart <unit> command it prints.

    Security architecture

    Four-layer defense model:

    1. Firewall (UFW): only SSH (22) exposed publicly, plus Tailscale (41641/udp) when enabled
    2. Loopback Gateway: the installer does not change OpenClaw's default loopback bind; reach it through an SSH tunnel or Tailscale Serve
    3. Docker isolation: DOCKER-USER iptables chain prevents external port exposure
    4. Unprivileged user: the Gateway runs as openclaw with scoped sudo and without membership in the root-equivalent docker group

    The installer does not harden the Gateway's systemd unit. Inspect it as the openclaw user with systemctl --user show openclaw-gateway.service -p NoNewPrivileges -p PrivateTmp -p ProtectSystem.

    Check which ports are publicly reachable:

    bash
    nmap -p- YOUR_SERVER_IP

    Only port 22 (SSH) should be open. Gateway and Docker stay locked down.

    Docker is installed for agent sandboxes (isolated tool execution), not for running the gateway. See Multi-agent sandbox and tools for sandbox configuration.

    Manual installation

  • Install prerequisites

    bash
    sudo apt update && sudo apt install -y ansible git
  • Clone the repository

    bash
    git clone https://github.com/openclaw/openclaw-ansible.gitcd openclaw-ansible
  • Install Ansible collections

    bash
    ansible-galaxy collection install -r requirements.yml
  • Run the playbook

    bash
    ./run-playbook.sh

    Or run the playbook directly, then continue with Post-install setup:

    bash
    ansible-playbook playbook.yml --ask-become-pass
  • Updating

    The Ansible installer sets up OpenClaw for manual updates; see Updating for the standard flow.

    To re-run the playbook (for example, after configuration changes):

    bash
    cd openclaw-ansible./run-playbook.sh

    You can run this multiple times without duplicating its effects.

    Troubleshooting

    Firewall blocks my connection
    • SSH (port 22) is always allowed. The Gateway listens on loopback; use an SSH tunnel or Tailscale Serve.
    Service will not start

    Run these as the openclaw user (sudo -i -u openclaw):

    bash
    # Check service state and logsopenclaw gateway statussystemctl --user status openclaw-gateway.serviceopenclaw logs # Verify permissionsls -la ~/.openclaw ~/.config/systemd/user # Test manual startopenclaw gateway run
    Docker sandbox issues

    Run these from your administrator account, not as openclaw: the openclaw user has neither Docker access nor general sudo rights.

    bash
    # Verify Docker is runningsudo systemctl status docker # Check sandbox imagesudo docker images | grep openclaw-sandbox

    If the image is missing, build it from a source checkout that your administrator account owns, not from a checkout the openclaw user can write to. See Images and setup.

    Channel login fails

    Make sure you are running as the openclaw user:

    bash
    sudo -i -u openclawopenclaw channels login --channel <name>

    Advanced configuration

    For detailed security architecture and troubleshooting, see the openclaw-ansible repo:

    Was this useful?