SuperAPI AI Directory

openclaw-deploy

Deployment & operations

View repository

Updated 10-16 00:04

About this skill

OpenClaw Remote One-Click Deployment

Automatically deploy OpenClaw + AI model + chat channel on a remote Linux server.


Step Zero: Output the Idiot-Proof Tutorial

After the skill starts, you must first output the following preparation checklist, so the user knows what is needed, and then use AskUserQuestion to collect information:

# OpenClaw 一键部署

欢迎!部署前你需要准备以下东西:
No. What to Prepare Description Required?
1 A Linux server Minimum 1GB RAM + 500MB disk, supports SSH login Required
2 SSH passwordless login Ensure the local machine can ssh user@host connect directly Required
3 AI model API Key Choose any of Zhipu GLM / DeepSeek / OpenAI / Claude / Kimi / Tongyi Required
4 Chat channel Bot Token Telegram (@BotFather) or Discord or Feishu; can also be left unconfigured for now Optional
5 Proxy address Required for mainland China servers + overseas channels (Telegram/Discord) Depends
6 Browser control Lets the Bot control the browser to search/take screenshots/fill forms; requires additionally installing Playwright Optional

---

## 第一步:收集信息

用 AskUserQuestion 收集($ARGUMENTS 已提供的跳过)。分两轮问:

### 第一轮(必填 3 项):

用 AskUserQuestion 同时问以下 3 个问题:

1. **SSH 连接信息**(header: "SSH 连接")
   - 选项根据上下文动态生成(如之前用过的服务器),兜底选项"其他服务器"
2. **AI 模型**(header: "AI 模型")
   - 智谱 GLM-5(国产,无需代理)
   - DeepSeek(国产,无需代理)
   - OpenAI GPT-4o(需代理或海外服务器)
   - Anthropic Claude(需代理或海外服务器)
3. **聊天频道**(header: "聊天频道")
   - Telegram(需 Bot Token,中国大陆需代理)
   - Discord(需 Bot Token)
   - 飞书(需 Bot Token)
   - 暂不配置
4. **浏览器控制**(header: "浏览器")
   - 启用(Bot 可操控浏览器搜索/截图/填表)
   - 暂不配置

### 第二轮(根据第一轮结果追问):

- 如果用户没提供 API Key → 问 API Key
- 如果选了聊天频道 → 问 Bot Token
  - 如果用户没有 Bot Token → 给出创建教程:
    - Telegram:找 @BotFather,发 `/newbot`
    - Discord:去 discord.com/developers 创建 Application → Bot
    - 飞书:去 open.feishu.cn 创建自建应用
- 如果选了 Telegram/Discord 且服务器在中国大陆 → 问代理地址
  - 自动判断:如果 SSH 到服务器后 `curl -s --connect-timeout 3 https://api.telegram.org` 失败,则判定需要代理

---

## 第二步:环境检查

SSH 连接到服务器,**单条命令**获取全部信息:

```bash
ssh <SSH_ARGS> "echo '=== CPU ===' && nproc && echo '=== 内存 ===' && free -h && echo '=== 磁盘 ===' && df -h / && echo '=== 系统 ===' && uname -a && echo '=== Node.js ===' && node -v 2>/dev/null || echo '未安装' && echo '=== npm ===' && npm -v 2>/dev/null || echo '未安装' && echo '=== 包管理器 ===' && which pacman apt yum dnf 2>/dev/null && echo '=== OpenClaw ===' && openclaw --version 2>/dev/null || echo '未安装'"

Minimum requirements: 1GB RAM + 500MB disk. If not met, inform the user and stop.


Step Three: Install Node.js (if not installed)

According to the detected package manager:

Package Manager Command
pacman (Arch) pacman -S --noconfirm nodejs npm
apt (Debian/Ubuntu) curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && apt install -y nodejs
dnf (RHEL/Fedora) dnf install -y nodejs npm
yum (CentOS) curl -fsSL https://rpm.nodesource.com/setup_22.x | bash - && yum install -y nodejs

Verify after installation:node -v && npm -v, confirm Node.js >= 22.


Step Four: Install OpenClaw

curl -fsSL https://openclaw.ai/install.sh | bash

Important: The installation script will try to start the interactive onboarding wizard, and in a non-TTY environment it will report a /dev/tty: No such device or address error.This is normal, the OpenClaw itself has been installed successfully.

Verify:openclaw --version


Step Five: Write the Configuration File

Write directly to ~/.openclaw/openclaw.json, without using the interactive wizard.

Model Configuration Template

{
  "models": {
    "mode": "merge",
    "providers": {
      "<PROVIDER_NAME>": {
        "baseUrl": "<BASE_URL>",
        "apiKey": "<API_KEY>",
        "api": "openai-completions",
        "models": [
          {
            "id": "<MODEL_ID>",
            "name": "<DISPLAY_NAME>",
            "reasoning": false,
            "input": ["text"],
            "contextWindow": 128000,
            "maxTokens": 32000
          }
        ]
      }
    }
  },
  "agents": {
    "defaults": {
      "model": {
        "primary": "<PROVIDER_NAME>/<MODEL_ID>"
      },
      "memorySearch": {
        "enabled": false
      }
    }
  },
  "gateway": {
    "mode": "local"
  }
}

Common Model Reference

Provider Name MODEL_ID baseUrl
zhipu glm-5 https://open.bigmodel.cn/api/paas/v4
openai gpt-4o https://api.openai.com/v1
deepseek deepseek-chat https://api.deepseek.com/v1
kimi moonshot-v1-128k https://api.moonshot.cn/v1
qwen qwen-max https://dashscope.aliyuncs.com/compatible-mode/v1
anthropic claude-sonnet-4-5-20250929 https://api.anthropic.com/v1

Note: For Anthropic models, the api field should be "anthropic-messages" rather than "openai-completions"。

Fix permissions immediately after writing:

mkdir -p ~/.openclaw/agents/main/sessions ~/.openclaw/credentials
chmod 700 ~/.openclaw
chmod 600 ~/.openclaw/openclaw.json

Step Six: Start the Gateway (systemd)

Execute in order:

# 安装 systemd 服务
openclaw gateway install

# 启用 linger(退出 SSH 后服务不会停)
loginctl enable-linger $(whoami)

# 启动
export XDG_RUNTIME_DIR=/run/user/$(id -u)
systemctl --user start openclaw-gateway.service

Wait 3 seconds and verify:

systemctl --user status openclaw-gateway.service | head -10

Confirm Active: active (running)。

Rotate device token

After the gateway starts for the first time, rotate the operator token to fix possible authentication issues:

# 先获取 device ID
DEVICE_ID=$(openclaw devices list 2>&1 | grep -oP '[a-f0-9]{40,}')
# 轮换 token
openclaw devices rotate --role operator --device "$DEVICE_ID"

Step Seven: Configure Chat Channel (if needed)

Perform the corresponding configuration according to the channel selected by the user.

7a. Set up channel

Telegram:

openclaw config set channels.telegram.enabled true
openclaw config set channels.telegram.botToken '<BOT_TOKEN>'
openclaw config set channels.telegram.dmPolicy pairing

Discord:

openclaw config set channels.discord.enabled true
openclaw config set channels.discord.botToken '<BOT_TOKEN>'
openclaw config set channels.discord.dmPolicy pairing

Feishu:

openclaw config set channels.feishu.enabled true
openclaw config set channels.feishu.token '<BOT_TOKEN>'
openclaw config set channels.feishu.dmPolicy pairing

7b. Configure proxy (required for mainland China servers + overseas channels)

Applicable scenario: The server is in mainland China, and the channel is Telegram or Discord (requires access to overseas APIs). Feishu is a domestic service and does not require a proxy.

First test whether a proxy is needed (automatic determination):

# Telegram
curl -s --connect-timeout 3 https://api.telegram.org/bot<BOT_TOKEN>/getMe
# Discord
curl -s --connect-timeout 3 https://discord.com/api/v10/users/@me -H "Authorization: Bot <BOT_TOKEN>"

If it times out/fails, it means a proxy is needed. Test with the proxy provided by the user:

export http_proxy='<PROXY_URL>' && export https_proxy='<PROXY_URL>'
curl -s --connect-timeout 5 https://api.telegram.org/bot<BOT_TOKEN>/getMe

After confirming it returns successfully, write the systemd override.

Important: proxy.conf mustwrite all environment variables in one go(proxy + no_proxy + DISPLAY), do not append them in multiple steps; subsequent browser steps also do not need to modify this file again.

mkdir -p ~/.config/systemd/user/openclaw-gateway.service.d
cat > ~/.config/systemd/user/openclaw-gateway.service.d/proxy.conf << EOF
[Service]
Environment="http_proxy=<PROXY_URL>"
Environment="https_proxy=<PROXY_URL>"
Environment="no_proxy=127.0.0.1,localhost,::1"
Environment="NO_PROXY=127.0.0.1,localhost,::1"
Environment="DISPLAY=:99"
EOF

Why is no_proxyneeded: without it, OpenClaw will also route through the proxy when connecting to the local Chrome CDP port, causing the browser to start successfully but OpenClaw to fail to detect it, reporting Failed to start Chrome CDP. Even if the browser is not configured currently, no_proxymust still be added to prevent pitfalls when enabling the browser later.

Why is DISPLAY=:99needed: the browser needs a display server, even in headless mode. If the browser is not configured, this variable is harmless.

7c. Restart the gateway (must be via systemd!)

Key pitfall:openclaw config set will trigger an internal hot restart, but a hot restartwill notload systemd's environment variables (proxy). After all configuration changes involving channels/proxies are completed, you must use systemctl --user restart to restart.

export XDG_RUNTIME_DIR=/run/user/$(id -u)
systemctl --user daemon-reload
systemctl --user restart openclaw-gateway.service

7d. Verify the channel connection

After waiting 5 seconds:

openclaw channels status

Confirm the output contains enabled, configured, running。

If you see fetch failed or Network request failed: the proxy is not in effect; check proxy.conf and confirm that it was restarted via systemctl.

7e. Pair the user

Have the user send a message to the Bot in the corresponding channel. The Bot will reply with a pairing code.

Key pitfall: the pairing command is openclaw pairing approve <channel> <CODE>, not openclaw devices approve <CODE>(that one will report unknown requestId)。

# 查看待配对列表(必须指定频道名)
openclaw pairing list <channel>
# 例如:openclaw pairing list telegram

# 批准配对
openclaw pairing approve <channel> <PAIRING_CODE>
# 例如:openclaw pairing approve telegram BAEWET79

The pairing code is valid for about 1 hour. If it expires, have the user send the message again to generate a new code.


Extended Reference

Detailed material starting at ## 第八步:配置浏览器控制(可选) has been moved to reference/extended.md to keep this skill concise. Load that reference when the task requires the moved examples, command catalogs, checklists, platform details, or implementation templates.