Ubuntu 部署 OpenClaw 完整教程
Ubuntu 部署 OpenClaw 需配置 Node.js 环境与系统依赖。通过 NodeSource 安装 LTS 版本并设置 npm 镜像。执行官方脚本完成安装,修正 PATH 环境变量。使用 SSH 隧道访问 Web 控制界面,支持飞书等渠道接入。流程涵盖环境准备、脚本安装、路径修复及远程连接测试。

Ubuntu 部署 OpenClaw 需配置 Node.js 环境与系统依赖。通过 NodeSource 安装 LTS 版本并设置 npm 镜像。执行官方脚本完成安装,修正 PATH 环境变量。使用 SSH 隧道访问 Web 控制界面,支持飞书等渠道接入。流程涵盖环境准备、脚本安装、路径修复及远程连接测试。

sudo apt update
sudo apt install -y curl
# 添加 NodeSource 仓库并安装
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs
# 安装完成后,验证版本
node -v
npm -v
实际输出:
ubuntu@gt-ubuntu22-04-cmd-v3-0-8gb-100m:~$ node -v
v24.14.0
ubuntu@gt-ubuntu22-04-cmd-v3-0-8gb-100m:~$ npm -v
11.9.0
npm config set registry https://registry.npmmirror.com
# 查询是否配置成功
npm config get registry
验证输出:
ubuntu@gt-ubuntu22-04-cmd-v3-0-8gb-100m:~$ npm config get registry
https://registry.npmmirror.com
执行安装脚本(注意:安装过程中要勾选 yes):
curl -fsSL https://openclaw.ai/install.sh | bash
完整安装日志:
ubuntu@gt-ubuntu22-04-cmd-v3-0-8gb-100m:~$ curl -fsSL https://openclaw.ai/install.sh | bash
🦞 OpenClaw Installer
The only crab in your contacts you actually want to hear from.
🦞 ✓ Detected: linux
Install plan
OS: linux
Install method: npm
Requested version: latest
[1/3] Preparing environment
✓ Node.js v24.14.0 found
· Active Node.js: v24.14.0 (/usr/bin/node)
· Active npm: 11.9.0 (/usr/bin/npm)
[2/3] Installing OpenClaw
✓ Git already installed
· Configuring npm for user-local installs
✓ npm configured for user installs
· Installing OpenClaw v2026.2.26
✓ OpenClaw npm package installed
✓ OpenClaw installed
[3/3] Finalizing setup
!PATH missing npm global bin dir: /home/ubuntu/.npm-global/bin
This can make openclaw show as "command not found" in new terminals.
Fix (zsh: ~/.zshrc, bash: ~/.bashrc):
export PATH="/home/ubuntu/.npm-global/bin:$PATH"
🦞 OpenClaw installed successfully (2026.2.26)! All done!
I promise to only judge your code a little bit.
· Starting setup
🦞 OpenClaw 2026.2.26 (bc50708) — Ship fast, log faster.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
██░▄▄▄░██░▄▄░██░▄▄▄██░▀██░██░▄▄▀██░████░▄▄▀██░███░██
██░███░██░▀▀░██░▄▄▄██░█░█░██░█████░████░▀▀░██░█░█░██
██░▀▀▀░██░█████░▀▀▀██░██▄░██░▀▀▄██░▀▀░█░██░██▄▀▄▀▄██
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
🦞 OPENCLAW 🦞
┌ OpenClaw onboarding
│ ◇ Security ─────────────────────────────────────────────────────────────────────────────────╮
│ │
│ Security warning — please read.
│ │
│ OpenClaw is a hobby project and still in beta. Expect sharp edges.
│ By default, OpenClaw is a personal agent: one trusted operator boundary.
│ This bot can read files and run actions if tools are enabled.
│ A bad prompt can trick it into doing unsafe things.
│ │
│ OpenClaw is not a hostile multi-tenant boundary by default.
│ If multiple users can message one tool-enabled agent, they share that delegated tool
│ authority.
│ │
│ If you're not comfortable with security hardening 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.
│ - Multi-user/shared inbox: split trust boundaries (separate gateway/credentials, ideally
│ separate OS users/hosts).
│ - Sandbox + least-privilege tools.
│ - Shared inboxes: isolate DM sessions (`session.dmScope: per-channel-peer`) and keep
│ tool access minimal.
│ - 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 personal-by-default and shared/multi-user use requires lock-down. 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
Z.AI
│ ◇ Z.AI auth method
CN
│ ◇ How do you want to provide this API key?
Paste API key now
│ ◇ Enter Z.AI API key
xxx.xxxx
│ ◇ Model configured ───────────────╮
│ │
│ Default model set to zai/glm-5
│ │
├──────────────────────────────────╯
│ ◇ Default model
zai/glm-4.7
│ ◇ Channel status ────────────────────────────╮
│ │
│ Telegram: needs token
│ WhatsApp (default): not linked
│ Discord: needs token
│ Slack: needs tokens
│ Signal: needs setup
│ signal-cli: missing (signal-cli)
│ iMessage: needs setup
│ imsg: missing (imsg)
│ IRC: not configured
│ Google Chat: 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
Updated ~/.openclaw/openclaw.json
Workspace OK: ~/.openclaw/workspace
Sessions OK: ~/.openclaw/agents/main/sessions
│ ◇ Skills status ─────────────╮
│ │
│ Eligible: 4
│ Missing requirements: 40
│ 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/ubuntu/.openclaw/openclaw.json (sha256 f763f7d577aba2ed75a863a91e3e9a116eab6ecc856e7731972988b006426453 -> 8eac9ee80087618bf88b5f7a2f1f6bdb4b5abf5dfa646c22bf65f64e92063204, backup=/home/ubuntu/.openclaw/openclaw.json.bak)
│ ◇ Systemd ────────────────────────────────────────────────────────────────────────────────╮
│ │
│ Linux installs use a systemd user service by default. Without lingering, systemd stops
│ the user session on logout/idle and kills the Gateway.
│ Enabling lingering now (may require sudo; writes /var/lib/systemd/linger).
│ │
├──────────────────────────────────────────────────────────────────────────────────────────╯
│ ◇ Systemd ───────────────────────────────╮
│ │
│ Enabled systemd lingering for ubuntu.
│ │
├─────────────────────────────────────────╯
│ ◇ Gateway service runtime ────────────────────────────────────────────╮
│ │
│ QuickStart uses Node for the Gateway service(stable + supported).
│ │
├──────────────────────────────────────────────────────────────────────╯
│ ◐ Installing Gateway service… Installed systemd service: /home/ubuntu/.config/systemd/user/openclaw-gateway.service
◇ Gateway service installed.
│ ◇ Agents: main (default)
Heartbeat interval: 30m (main)
Session store (main): /home/ubuntu/.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=YOUR_TOKEN
│ 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?
Open the Web UI
│ ◇ Dashboard ready ────────────────────────────────────────────────────────────────╮
│ │
│ Dashboard link(with token):
│ http://127.0.0.1:18789/#token=YOUR_TOKEN
│ Copy/paste this URL in a browser on this machine to control OpenClaw.
│ No GUI detected. Open from your computer:
│ ssh -N -L 18789:127.0.0.1:18789 [email protected]
│ Then open:
│ http://localhost:18789/
│ http://localhost:18789/#token=YOUR_TOKEN
│ Docs:
│ https://docs.openclaw.ai/gateway/remote
│ https://docs.openclaw.ai/web/control-ui
│ │
├──────────────────────────────────────────────────────────────────────────────────╯
│ ◇ Workspace backup ────────────────────────────────────────╮
│ │
│ Back up your agent workspace.
│ Docs: https://docs.openclaw.ai/concepts/agent-workspace
│ │
├───────────────────────────────────────────────────────────╯
│ ◇ Security ──────────────────────────────────────────────────────╮
│ │
│ Running agents on your computer is risky — harden your setup:
│ https://docs.openclaw.ai/security
│ │
├─────────────────────────────────────────────────────────────────╯
│ ◇ Shell completion ────────────────────────────────────────────────────────╮
│ │
│ Shell completion installed. Restart your shell or run: source ~/.bashrc
│ │
├───────────────────────────────────────────────────────────────────────────╯
│ ◇ Web search (optional) ─────────────────────────────────────────────────────────────────╮
│ │
│ If you want your agent to be able to search the web, you'll need an API key.
│ │
│ OpenClaw uses Brave Search for the `web_search` tool. Without a Brave Search API key,
│ web search won't work.
│ │
│ Set it up interactively:
│ - Run: openclaw configure --section web
│ - Enable web_search and paste your Brave Search API key
│ │
│ Alternative: set BRAVE_API_KEY in the Gateway environment (no config changes).
│ Docs: https://docs.openclaw.ai/tools/web
│ │
├─────────────────────────────────────────────────────────────────────────────────────────╯
│ ◇ What now ─────────────────────────────────────────────────────────────╮
│ │
│ What now: https://openclaw.ai/showcase ("What People Are Building").
│ │
├────────────────────────────────────────────────────────────────────────╯
│ └ Onboarding complete. Use the dashboard link above to control OpenClaw.
ubuntu@gt-ubuntu22-04-cmd-v3-0-8gb-100m:~$
安装完成后,如果执行 which openclaw 找不到命令,需要手动配置 PATH:
# 检查 openclaw 是否在 PATH 中
which openclaw
# 如果找不到,查看 npm 全局安装目录
npm prefix -g
# 查看当前 shell
echo $SHELL
# 如果输出 /bin/bash,使用 ~/.bashrc
# 如果输出 /bin/zsh,使用 ~/.zshrc
# 将 npm 全局 bin 目录添加到 PATH
echo 'export PATH="$(npm prefix -g)/bin:$PATH"' >> ~/.bashrc
# 重新加载配置文件
source ~/.bashrc
# 验证添加是否成功
echo $PATH | grep npm
在本地电脑执行,按提示输入远程 Linux 云主机密码即可:
ssh -N -L 18789:127.0.0.1:18789 ubuntu@<server_ip>
携带部署过程中生成的 Dashboard link 在本地进行访问。
http://localhost:18789/#token=YOUR_TOKEN
本文详细记录了在 Ubuntu 22.04 服务器上从零部署 OpenClaw 的完整流程,包括:

微信公众号「极客日志」,在微信中扫描左侧二维码关注。展示文案:极客日志 zeeklog
生成新的随机RSA私钥和公钥pem证书。 在线工具,RSA密钥对生成器在线工具,online
基于 Mermaid.js 实时预览流程图、时序图等图表,支持源码编辑与即时渲染。 在线工具,Mermaid 预览与可视化编辑在线工具,online
将字符串编码和解码为其 Base64 格式表示形式即可。 在线工具,Base64 字符串编码/解码在线工具,online
将字符串、文件或图像转换为其 Base64 表示形式。 在线工具,Base64 文件转换器在线工具,online
将 Markdown(GFM)转为 HTML 片段,浏览器内 marked 解析;与 HTML转Markdown 互为补充。 在线工具,Markdown转HTML在线工具,online
将 HTML 片段转为 GitHub Flavored Markdown,支持标题、列表、链接、代码块与表格等;浏览器内处理,可链接预填。 在线工具,HTML转Markdown在线工具,online