---
title: "How to install an OpenClaw agent on a VPS"
description: "OpenClaw (successor to Moltbot and Clawdbot) is the new evolved version of the autonomous AI assistant. This guide uses Docker to protect your host system while"
url: https://docs.us.ovhcloud.com/en/bare-metal-cloud/vps/install-openclaw-agent
lang: en
---
> For AI agents: the complete documentation index is available at https://docs.us.ovhcloud.com/en/llms.txt, the full documentation bundle is available at https://docs.us.ovhcloud.com/en/llms-full.txt.

# How to install an OpenClaw agent on a VPS

**OpenClaw** (successor to Moltbot and Clawdbot) is the new evolved version of the autonomous AI assistant. This guide uses **Docker** to protect your host system while ensuring your assistant remains online 24/7.

 

## Requirements

- An active [OVHcloud VPS](https://us.ovhcloud.com/vps/) (Debian 11/12 or Ubuntu 22.04+); refer to our guide "[Getting started with a VPS](https://docs.us.ovhcloud.com/en/bare-metal-cloud/vps/starting-with-a-vps.md)"
- SSH access to your VPS
- An API key (Anthropic or OpenAI)

 

## Instructions

**Table of contents:**

- [Step 1 - Install Docker](#step-1-install-docker)
- [Step 2 - Prepare directories](#step-2-prepare-directories)
- [Step 3 - Deployment configuration (Docker Compose)](#step-3-deployment-configuration)
- [Step 4 - Launch the agent](#step-4-launch)
- [Step 5 - Secure access via an SSH tunnel](#step-5-secure-access-via-an-ssh-tunnel)

 

### Step 1 - Install Docker

On your VPS, install Docker and its Compose plugin:

```
curl -fsSL https://get.docker.com | sudo sh
sudo usermod -aG docker $USER
```

_Note: Log out and log back in via SSH for the Docker group addition to take effect._

 

### Step 2 - Prepare directories

Docker needs folders on your VPS to store data permanently (WhatsApp sessions, memory).

```
mkdir -p ~/openclaw/data
cd ~/openclaw
```

 

### Step 3 - Deployment configuration

Create a file named docker-compose.yml in this folder:

```
nano docker-compose.yml
```

Copy the following configuration into it:

```
services:
  openclaw:
    image: ghcr.io/openclaw/openclaw:latest
    container_name: openclaw-gateway
    restart: always
    ports:
      - "127.0.0.1:18789:18789"
    volumes:
      - ~/openclaw/data:/home/node/.openclaw
    environment:
      - NODE_ENV=production

```

**Warning:**

**Security:** By using 127.0.0.1:18789:18789, the port is exposed only within the VPS. No one can access it from the outside without the SSH tunnel.

 

### Step 4 - Launch

Start your agent:

```
docker compose up -d
```

 

### Step 5 - Secure access via an SSH tunnel

1. **On your personal computer**, create the tunnel.

   The method remains the same. From your personal computer, open a terminal:

   - Windows: PowerShell or Command Prompt (cmd).
   - Linux / macOS: Terminal.

   ```
   ssh -L 18789:127.0.0.1:18789 user@YOUR_VPS_IP
   ```

   _Keep this terminal window open for the entire duration of your use._

2. **On your VPS (another terminal window)**, retrieve your access token:

   ```
   cat ~/openclaw/data/openclaw.json | grep '"token":'
   ```

   Open your browser and go to: `http://127.0.0.1:18789`.

_Tip: If the interface remains disconnected, you can force the connection by using your token directly in the URL: `http://127.0.0.1:18789/?token=YOUR_GATEWAY_TOKEN`_

The rest takes place in the **Overview** menu: enter your **Gateway Token** to log in.

 

## Go further

[Secure an OVHcloud VPS](https://docs.us.ovhcloud.com/en/bare-metal-cloud/vps/secure-your-vps.md)

[Official OpenClaw documentation](https://docs.openclaw.ai/)

Browse all the [Virtual Private Servers guides](https://docs.us.ovhcloud.com/en/bare-metal-cloud/vps/landing-page-vps.md).

Browse the rest of the [OVHcloud US documentation](https://docs.us.ovhcloud.com/en/index.md) for guides on our other products and services.

Learn more about [VPS](https://us.ovhcloud.com/vps/) on the OVHcloud US website.
