openclaw 安装部署
ufw
本文字数:2.1k 字 | 阅读时长 ≈ 11 min

openclaw 安装部署

ufw
本文字数:2.1k 字 | 阅读时长 ≈ 11 min

最近小龙虾🦞比较火,跟风安装一下,配置是这样的:Ubuntu 无图形界面安装 OpenClaw + GitHub Copilot + Telegram 正确流程,环境如下

1. OpenClaw 版本

当前出到了 2026.3.11 但是因为新版号线不支持本地 https 代理(我用本地代理 copilot 一直登录失败具体原因可以参考),因此建议直接安装:2026.2.23

开代理以后 copilot 显示登录失败

Requesting device code from GitHub... 
TypeError: fetch failed

2. 安装 Node 与 OpenClaw

如果本机已经有 Node 和 npm,可以直接继续。如果没有,就先安装 Node.js

node -v
npm -v
npm prefix -g

安装 OpenClaw,这里不安装 latest,直接安装 2026.2.23,安装完后看看版本,如果这里显示的是 2026.2.23,说明安装正确

➜ ~ npm install -g openclaw@2026.2.23
➜ ~ openclaw --version
npm list -g openclaw --depth=0
2026.2.23
/home/yonghuiwang/.npm-global/lib
└── openclaw@2026.2.23

如果执行 openclaw --version 报:zsh: command not found: openclaw,大概率是 npm 用户级全局安装目录不在 PATH 里

➜ ~ npm prefix -g
echo "$PATH"
/home/yonghuiwang/.npm-global
/home/yonghuiwang/.autojump/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:...

npm 全局目录是 ~/.npm-global,但 ~/.npm-global/bin 没进 PATH,执行下面命令,此时在运行就可以出现正确的版本了

echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
echo "$PATH"
which openclaw || ls -l ~/.npm-global/bin
➜ ~ source ~/.zshrc
echo "$PATH"
which openclaw || ls -l ~/.npm-global/bin
/home/yonghuiwang/.npm-global/bin:/home/yonghuiwang/.autojump/bin:/usr/local/sbin:/usr/local/bin:...
/home/yonghuiwang/.npm-global/bin/openclaw

3. 配置目录

如果你之前已经装过 OpenClaw,或者曾经试过高版本,一定不要直接沿用旧配置。必须保证 ~/.openclaw 是干净的,如果以前没安装过,跳过这里,如果你以前装过,先备份旧配置

mv ~/.openclaw ~/.openclaw.bak.$(date +%Y%m%d-%H%M%S) 2>/dev/null || true
mkdir -p ~/.openclaw
ls -ld ~/.openclaw ~/.openclaw.bak.* 2>/dev/null || true

# 大概输出是这样的
➜ ~ ls -ld ~/.openclaw ~/.openclaw.bak.*
drwxrwxr-x  2 yonghuiwang yonghuiwang 4096 Mar 13 01:59 /home/yonghuiwang/.openclaw
drwx------ 11 yonghuiwang yonghuiwang 4096 Mar 13 01:42 /home/yonghuiwang/.openclaw.bak.20260313-015934

4. 配置代理

因为我们的模型可能是用国外的模型,所以需要设置 http 代理,我之前用了 v2ray 搭建代理在 10808 和 10809 端口

cat > ~/.openclaw/.env <<EOF
HTTP_PROXY=http://127.0.0.1:10809
HTTPS_PROXY=http://127.0.0.1:10809
ALL_PROXY=socks5://127.0.0.1:10808
http_proxy=http://127.0.0.1:10809
https_proxy=http://127.0.0.1:10809
all_proxy=socks5://127.0.0.1:10808
EOF

chmod 600 ~/.openclaw/.env
wc -l ~/.openclaw/.env

5. 配置 openclaw

运行 openclaw onboard,这里直接展示整个流程的 shell,看起来最直观

➜ ~ openclaw onboard

🦞 OpenClaw 2026.2.23 (b817600) — Meta wishes they shipped this fast.

▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
██░▄▄▄░██░▄▄░██░▄▄▄██░▀██░██░▄▄▀██░████░▄▄▀██░███░██
██░███░██░▀▀░██░▄▄▄██░█░█░██░█████░████░▀▀░██░█░█░██
██░▀▀▀░██░█████░▀▀▀██░██▄░██░▀▀▄██░▀▀░█░██░██▄▀▄▀▄██
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
                  🦞 OPENCLAW 🦞                    
 
┌  OpenClaw onboarding
│
◇  Security ──────────────────────────────────────────────────────────────────────────────╮
│                                                                                         │
│  Security warning — please read.                                                        │
│                                                                                         │
│  OpenClaw is a hobby project and still in beta. Expect sharp edges.                     │
│  This bot can read files and run actions if tools are enabled.                          │
│  A bad prompt can trick it into doing unsafe things.                                    │
│                                                                                         │
│  If you’re not comfortable with basic security and access control, don’t run OpenClaw.  │
│  Ask someone experienced to help before enabling tools or exposing it to the internet.  │
│                                                                                         │
│  Recommended baseline:                                                                  │
│  - Pairing/allowlists + mention gating.                                                 │
│  - Sandbox + least-privilege tools.                                                     │
│  - Keep secrets out of the agent’s reachable filesystem.                                │
│  - Use the strongest available model for any bot with tools or untrusted inboxes.       │
│                                                                                         │
│  Run regularly:                                                                         │
│  openclaw security audit --deep                                                         │
│  openclaw security audit --fix                                                          │
│                                                                                         │
│  Must read: https://docs.openclaw.ai/gateway/security                                   │
│                                                                                         │
├─────────────────────────────────────────────────────────────────────────────────────────╯
│
◇  I understand this is powerful and inherently risky. Continue?
│  Yes
│
◇  Onboarding mode
│  QuickStart
│
◇  QuickStart ─────────────────────────╮
│                                      │
│  Gateway port: 18789                 │
│  Gateway bind: Loopback (127.0.0.1)  │
│  Gateway auth: Token (default)       │
│  Tailscale exposure: Off             │
│  Direct to chat channels.            │
│                                      │
├──────────────────────────────────────╯
│
◇  Model/auth provider
│  Copilot
│
◇  Copilot auth method
│  GitHub Copilot (GitHub device login)
│
◇  GitHub Copilot ─────────────────────────────────────────────╮
│                                                              │
│  This will open a GitHub device login to authorize Copilot.  │
│  Requires an active GitHub Copilot subscription.             │
│                                                              │
├──────────────────────────────────────────────────────────────╯
┌  GitHub Copilot login
│
◇  Device code ready
│
◇  Authorize ──────────────────────────────╮
│                                          │
│  Visit: https://github.com/login/device  │
│  Code: 924F-893B                         │
│                                          │
├──────────────────────────────────────────╯
│
◇  GitHub access token acquired
Updated ~/.openclaw/openclaw.json
Auth profile: github-copilot:github (github-copilot/token)
│
└  Done

│
◇  Model configured ───────────────────────────╮
│                                              │
│  Default model set to github-copilot/gpt-4o  │
│                                              │
├──────────────────────────────────────────────╯
│
◇  Default model
│  Keep current (github-copilot/gpt-4o)
│
◇  Channel status ────────────────────────────╮
│                                             │
│  Telegram: not configured                   │
│  WhatsApp: not configured                   │
│  Discord: not configured                    │
│  IRC: not configured                        │
│  Google Chat: not configured                │
│  Slack: not configured                      │
│  Signal: not configured                     │
│  iMessage: not configured                   │
│  Feishu: install plugin to enable           │
│  Google Chat: install plugin to enable      │
│  Nostr: install plugin to enable            │
│  Microsoft Teams: install plugin to enable  │
│  Mattermost: install plugin to enable       │
│  Nextcloud Talk: install plugin to enable   │
│  Matrix: install plugin to enable           │
│  BlueBubbles: install plugin to enable      │
│  LINE: install plugin to enable             │
│  Zalo: install plugin to enable             │
│  Zalo Personal: install plugin to enable    │
│  Synology Chat: install plugin to enable    │
│  Tlon: install plugin to enable             │
│                                             │
├─────────────────────────────────────────────╯
│
◇  How channels work ───────────────────────────────────────────────────────────────────────╮
│                                                                                           │
│  DM security: default is pairing; unknown DMs get a pairing code.                         │
│  Approve with: openclaw pairing approve <channel> <code>                                  │
│  Public DMs require dmPolicy="open" + allowFrom=["*"].                                    │
│  Multi-user DMs: run: openclaw config set session.dmScope "per-channel-peer" (or          │
│  "per-account-channel-peer" for multi-account channels) to isolate sessions.              │
│  Docs: channels/pairing              │
│                                                                                           │
│  Telegram: simplest way to get started — register a bot with @BotFather and get going.    │
│  WhatsApp: works with your own number; recommend a separate phone + eSIM.                 │
│  Discord: very well supported right now.                                                  │
│  IRC: classic IRC networks with DM/channel routing and pairing controls.                  │
│  Google Chat: Google Workspace Chat app with HTTP webhook.                                │
│  Slack: supported (Socket Mode).                                                          │
│  Signal: signal-cli linked device; more setup (David Reagans: "Hop on Discord.").         │
│  iMessage: this is still a work in progress.                                              │
│  Feishu: 飞书/Lark enterprise messaging with doc/wiki/drive tools.                        │
│  Nostr: Decentralized protocol; encrypted DMs via NIP-04.                                 │
│  Microsoft Teams: Bot Framework; enterprise support.                                      │
│  Mattermost: self-hosted Slack-style chat; install the plugin to enable.                  │
│  Nextcloud Talk: Self-hosted chat via Nextcloud Talk webhook bots.                        │
│  Matrix: open protocol; install the plugin to enable.                                     │
│  BlueBubbles: iMessage via the BlueBubbles mac app + REST API.                            │
│  LINE: LINE Messaging API bot for Japan/Taiwan/Thailand markets.                          │
│  Zalo: Vietnam-focused messaging platform with Bot API.                                   │
│  Zalo Personal: Zalo personal account via QR code login.                                  │
│  Synology Chat: Connect your Synology NAS Chat to OpenClaw with full agent capabilities.  │
│  Tlon: decentralized messaging on Urbit; install the plugin to enable.                    │
│                                                                                           │
├───────────────────────────────────────────────────────────────────────────────────────────╯
│
◇  Select channel (QuickStart)
│  Skip for now
Config overwrite: /home/yonghuiwang/.openclaw/openclaw.json (sha256 ccbbd1630d59c509338390df1fed4ad63a58d65d2002bdd56608737804d936c7 -> 5b0b3160c0a086041e9c225e81ddcca06ed45166531dd75b8cb2f6a68fa2e48a, backup=/home/yonghuiwang/.openclaw/openclaw.json.bak)
Updated ~/.openclaw/openclaw.json
Workspace OK: ~/.openclaw/workspace
Sessions OK: ~/.openclaw/agents/main/sessions
│
◇  Skills status ─────────────╮
│                             │
│  Eligible: 5                │
│  Missing requirements: 39   │
│  Unsupported on this OS: 7  │
│  Blocked by allowlist: 0    │
│                             │
├─────────────────────────────╯
│
◇  Configure skills now? (recommended)
│  No
│
◇  Hooks ──────────────────────────────────────────────────────────────────╮
│                                                                          │
│  Hooks let you automate actions when agent commands are issued.          │
│  Example: Save session context to memory when you issue /new or /reset.  │
│                                                                          │
│  Learn more: https://docs.openclaw.ai/automation/hooks                   │
│                                                                          │
├──────────────────────────────────────────────────────────────────────────╯
│
◇  Enable hooks?
│  Skip for now
Config overwrite: /home/yonghuiwang/.openclaw/openclaw.json (sha256 5b0b3160c0a086041e9c225e81ddcca06ed45166531dd75b8cb2f6a68fa2e48a -> 0edc0704031d6e0e507e40de99c8b592f6bf0ec8c93b172c758e4492decca66b, backup=/home/yonghuiwang/.openclaw/openclaw.json.bak)
│
◇  Gateway service runtime ────────────────────────────────────────────╮
│                                                                      │
│  QuickStart uses Node for the Gateway service (stable + supported).  │
│                                                                      │
├──────────────────────────────────────────────────────────────────────╯
│
◇  Gateway service already installed
│  Restart
│
◒  Restarting Gateway service…Restarted systemd service: openclaw-gateway.service
◇  Gateway service restarted.

│

◇  
Agents: main (default)
Heartbeat interval: 30m (main)
Session store (main): /home/yonghuiwang/.openclaw/agents/main/sessions/sessions.json (0 entries)
│
◇  Optional apps ────────────────────────╮
│                                        │
│  Add nodes for extra features:         │
│  - macOS app (system + notifications)  │
│  - iOS app (camera/canvas)             │
│  - Android app (camera/canvas)         │
│                                        │
├────────────────────────────────────────╯
│
◇  Control UI ─────────────────────────────────────────────────────────────────────╮
│                                                                                  │
│  Web UI: http://127.0.0.1:18789/                                                 │
│  Web UI (with token):                                                            │
│  http://127.0.0.1:18789/#token=9752152308d7ebca72bc63e9bd1f46ad47a026bdd68f1356  │
│  Gateway WS: ws://127.0.0.1:18789                                                │
│  Gateway: reachable                                                              │
│  Docs: https://docs.openclaw.ai/web/control-ui                                   │
│                                                                                  │
├──────────────────────────────────────────────────────────────────────────────────╯
│
◇  Start TUI (best option!) ─────────────────────────────────╮
│                                                            │
│  This is the defining action that makes your agent you.    │
│  Please take your time.                                    │
│  The more you tell it, the better the experience will be.  │
│  We will send: "Wake up, my friend!"                       │
│                                                            │
├────────────────────────────────────────────────────────────╯
│
◇  Token ─────────────────────────────────────────────────────────────────────────────────╮
│                                                                                         │
│  Gateway token: shared auth for the Gateway + Control UI.                               │
│  Stored in: ~/.openclaw/openclaw.json (gateway.auth.token) or OPENCLAW_GATEWAY_TOKEN.   │
│  View token: openclaw config get gateway.auth.token                                     │
│  Generate token: openclaw doctor --generate-gateway-token                               │
│  Web UI stores a copy in this browser's localStorage (openclaw.control.settings.v1).    │
│  Open the dashboard anytime: openclaw dashboard --no-open                               │
│  If prompted: paste the token into Control UI settings (or use the tokenized dashboard  │
│  URL).                                                                                  │
│                                                                                         │
├─────────────────────────────────────────────────────────────────────────────────────────╯
│
◇  How do you want to hatch your bot?
│  Hatch in TUI (recommended)
 openclaw tui - ws://127.0.0.1:18789 - agent main - session main                                                                                                                           

 session agent:main:main                                                                                                                                                                   

                                                                                                                                                                                           
 Wake up, my friend!                                                                                                                                                                       
                                                                                                                                                                                           

 Hello! I'm awake and ready to dive in. What's on your mind?                                                                                                                               
 gateway connected | idle                                                                                                                                                                  
 agent main | session main (openclaw-tui) | github-copilot/gpt-4o | tokens ?/64k                                                                                                           
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
                                                                                                                                                                                           
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

6. 查看是否配置成功

验证一下本地 agent 路径,出现回复说明没问题了

➜ ~ openclaw agent --agent main --message "Reply with exactly: OK" --local

🦞 OpenClaw 2026.2.23 (b817600) — iMessage green bubble energy, but for everyone.

OK

7. 添加 Telegram

再次运行 onboarding,当然了,你也可以在第一次运行 onboarding 的时候就配置,运行 openclaw onboard,出现大概下面内容

◇  Existing config detected

workspace: ~/.openclaw/workspace
model: github-copilot/gpt-4o
gateway.mode: local
gateway.port: 18789
gateway.bind: loopback

◆  Config handling
● Use existing values
○ Update values
○ Reset

◇  Select channel (QuickStart)

Telegram (Bot API)

然后输入你的 Telegram bot token。

例如输入类似这种格式的 token:

1234567890:AAxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

	•	Web search:Skip for now
	•	Skills:No
	•	Hooks:Skip for now

结束后在运行 openclaw status

┌─────────────────┬─────────────────────────────────────────────────────────────┐
│ Dashboard       │ http://127.0.0.1:18789/                                    │
│ Gateway         │ local · ws://127.0.0.1:18789 ... reachable ...            │
│ Sessions        │ 1 active · default gpt-4o (64k ctx) ...                   │
└─────────────────┴─────────────────────────────────────────────────────────────┘
Channels
┌──────────┬─────────┬────────┬─────────────────────────────────────────────┐
│ Channel  │ Enabled │ State  │ Detail                                      │
├──────────┼─────────┼────────┼─────────────────────────────────────────────┤
│ Telegram │ ON      │ OK     │ token config (8744…wAWU · len 46)          │
└──────────┴─────────┴────────┴─────────────────────────────────────────────┘

这时候就可以去 telegram 和小龙虾对话了,但是注意,第一次通常会进入 pairing 机制。OpenClaw 默认不会立刻信任陌生私聊用户,而是要求配对。

这时去服务器上查看 pairing 请求:openclaw pairing list --channel telegram

➜ ~ openclaw pairing list --channel telegram

🦞 OpenClaw 2026.2.23 (b817600) — Shell yeah—I'm here to pinch the toil and leave you the glory.

Pairing requests (1)
┌──────────┬─────────────────────┬───────────────────────────────────────────────────────────────┬──────────────────────────┐
│ Code     │ telegramUserId      │ Meta                                                          │ Requested                │
├──────────┼─────────────────────┼───────────────────────────────────────────────────────────────┼──────────────────────────┤
│ JSQXT4MP │ 1907660075          │ {"username":"harry_ice_tea","firstName":"hi",...}            │ 2026-03-12T18:10:31.437Z │

➜ ~ openclaw pairing approve telegram JSQXT4MP

🦞 OpenClaw 2026.2.23 (b817600) — If something's on fire, I can't extinguish it—but I can write a beautiful postmortem.

Approved telegram sender 1907660075.

到这里,这个 Telegram 用户就被批准了。接下来就可以对话了

12月 14, 2025
8月 26, 2025