Self-hosting

Self-hosting OpenClaw on a VPS for private Telegram AI access

A new guide details how to deploy the open-source OpenClaw assistant on a Ubuntu VPS, connecting it to Telegram with strict pairing-based security.

Illustration of a secure server with a Telegram icon
Illustration created for this article

OpenClaw offers a self-hosted alternative to cloud-based AI assistants by running locally on user hardware and maintaining persistent memory. A recent technical guide outlines the process for deploying this open-source tool on a virtual private server using Ubuntu and connecting it to Telegram for secure, always-on access.

What happened

The guide provides a step-by-step method for installing OpenClaw on a fresh Ubuntu 22.04 or 24.04 virtual private server. It emphasizes that while laptops can run the software, they are unreliable due to sleep modes, making a low-cost VPS from providers like Hetzner, DigitalOcean, Vultr, or Linode a more stable choice. The setup requires root SSH access, a Telegram account, and an API key from a model provider such as Anthropic or OpenAI, since OpenClaw operates on a bring-your-own-key basis.

Security is a central theme of the deployment process. The instructions mandate creating a dedicated non-root user for the application and configuring the firewall to allow only SSH traffic, explicitly leaving the gateway port closed to the public internet. The installation can be performed via an official script that handles Node.js provisioning or through npm, though the latter requires specific Node versions (24.16+ or 26.1+). Once installed, the software runs as a systemd daemon, ensuring it restarts automatically if it crashes or after a server reboot.

Connecting the assistant to Telegram involves creating a private bot via BotFather and configuring the OpenClaw channel settings. The guide highlights a critical security feature called pairing policy, which ensures the bot ignores messages from unknown users until an administrator approves them via a code generated on the server. This prevents unauthorized access to the assistant’s capabilities, which may include executing commands or accessing files.

Key details

  • OpenClaw runs on Ubuntu 22.04 or 24.04 with 1–2 GB of RAM, as heavy processing occurs at the model provider.
  • The gateway service listens on port 18789, which must remain bound to localhost and never exposed to the public internet.
  • Access control uses a pairing mechanism where new senders receive a code that must be approved via the command line within one hour.
  • Configuration supports environment variables for sensitive data like bot tokens, keeping them out of plain text config files.
  • The Control UI is accessed securely through an SSH tunnel from the user’s local machine rather than a public web interface.
  • Installation scripts handle runtime dependencies, but manual npm installs require Node 24.16+ or 26.1+ and may need swap space on small instances.

Background

Self-hosting AI assistants addresses privacy concerns associated with cloud platforms, where conversation history and data reside on third-party servers. By running the software on personal infrastructure, users retain full control over their data and session memory. OpenClaw acts as a bridge between large language models and chat applications, managing state locally while offloading actual inference to external API providers.

Running services on a VPS introduces operational responsibilities typically handled by cloud providers. Administrators must manage operating system updates, user permissions, and network security manually. Tools like systemd ensure service reliability, while firewalls like UFW restrict network exposure. Understanding these basics is essential for maintaining a secure and available self-hosted environment.

Why it matters

For teams and individuals who prioritize data sovereignty, this approach eliminates the risk of vendor lock-in and unexpected service termination. It allows for continuous availability of the assistant without relying on a specific device being powered on. However, it shifts the burden of uptime and security to the user, requiring vigilance in patching and configuration management.

The pairing-based access control model is particularly relevant for tools that can execute system commands. Unlike public bots that might respond to any user, this setup ensures that only verified individuals can interact with the assistant. This reduces the attack surface significantly, preventing unauthorized users from leveraging the AI to probe the server or access sensitive files.

Cost efficiency is another factor, as the VPS expense is fixed and low, while model usage costs are transparent and controllable via the provider’s console. This contrasts with subscription-based AI services that may have opaque pricing or limited features. Users can tailor the assistant’s behavior and connected skills to their specific workflow without being constrained by a platform’s predefined capabilities.

What you can do

  • Provision a small Ubuntu VPS and create a dedicated non-root user before installing any software.
  • Use the official installer script to avoid Node.js version conflicts, or verify your Node version meets the 24.16+ requirement.
  • Configure the firewall to block all inbound traffic except SSH, ensuring the gateway port remains inaccessible from the internet.
  • Store bot tokens and API keys in environment variables rather than hardcoding them in configuration files.
  • Enable the pairing policy for Telegram channels to prevent unauthorized users from interacting with your assistant.
  • Set up an SSH tunnel to access the Control UI securely without exposing the web interface to the public network.

More news

All news