openclaw在ubuntu系统的安装

openclaw在ubuntu系统的安装

一、环境要求

  • Node.js 22 或更高版本(推荐 LTS)
  • Node 24(推荐)(Node 22 LTS,目前 22.16+,仍兼容支持;安装脚本会在缺失时自动安装 Node 24)
  • 仅从源码构建时需要 pnpm

以下为Ubuntu 24.04 的安装过程

建议先拍个快照

二、安装

openclaw官网:https://openclaws.io/

一键安装命令

bash 复制代码
curl -fsSL https://openclaw.ai/install.sh | bash

安装过程

三、初始化配置

1.个人单用户使用选择Yes

2.选 QuickStart,会自动生成一套安全的默认配置,不用手动处理复杂选项,且后续所有细节都可以用 openclaw configure 命令修改

3.按需选择 AI 模型提供商、添加API Key

4.聊天对接通道,按需选,也可跳过

以飞书为例,需要在飞书开放平台 https://open.feishu.cn/的开发者后台中创建应用,再获取APP ID 和 APP Secret

5.安装Skills -- 可以先选「No」跳过,后续随时添加

配置完成后就可以对话交流

.env --- 所有配置存储在 ~/.openclaw/openclaw.json。可以直接编辑这个文件来切换供应商、添加 API Key 或调整设置。完整参考见 docs.openclaw.ai/configuration

四、配置局域网访问

查看网关状态

Gateway 服务没有在后台运行

bash 复制代码
root@huang:~# openclaw gateway status

OpenClaw 2026.5.20 (e510042) --- Hot reload for config, cold sweat for deploys.

│
◇  
Service: systemd user (disabled)
File logs: /tmp/openclaw/openclaw-2026-05-23.log

Config (cli): ~/.openclaw/openclaw.json
Config (service): ~/.openclaw/openclaw.json

Gateway: bind=loopback (127.0.0.1), port=18789 (env/config)
Probe target: ws://127.0.0.1:18789
Dashboard: http://127.0.0.1:18789/
Probe note: Loopback-only gateway; only local clients can connect.

Runtime: unknown (systemctl --user unavailable: Failed to connect to bus: No medium found)
Connectivity probe: failed
Probe target: ws://127.0.0.1:18789
  connect ECONNREFUSED 127.0.0.1:18789
Capability: unknown

systemd user services unavailable.
systemd user services are unavailable; install/enable systemd or run the gateway under your supervisor.
On a headless server (SSH/no desktop session): run `sudo loginctl enable-linger $(whoami)` to persist your systemd user session across logins.
Also ensure XDG_RUNTIME_DIR is set: `export XDG_RUNTIME_DIR=/run/user/$(id -u)`, then retry.
If you're in a container, run the gateway in the foreground instead of `openclaw gateway`.

Troubles: run openclaw status
Troubleshooting: https://docs.openclaw.ai/troubleshooting

4.1 修改配置文件

bash 复制代码
# 1. 修改 Gateway 绑定地址为 lan,允许局域网访问
openclaw config set gateway.bind lan

# 2. 重启 OpenClaw 网关,使配置生效
openclaw gateway restart

# 3. 在主机上开一个终端启动网关
openclaw gateway run

# 4. 验证服务是否已正确监听在 0.0.0.0:18789 (看到 0.0.0.0:18789 即正常)
root@huang:~# netstat -tulnp | grep 18789
tcp        0      0 0.0.0.0:18789           0.0.0.0:*               LISTEN      4759/openclaw   

查看仪表盘

bash 复制代码
root@huang:~# openclaw dashboard
│
◇  

OpenClaw 2026.5.20 (e510042) --- I'm like tmux: confusing at first, then suddenly you can't live without me.

│
◇  
Dashboard URL: http://127.0.0.1:18789/
Token auto-auth included in browser/clipboard URL.
Copy to clipboard unavailable.
No GUI detected. Open from your computer:
ssh -N -L 18789:127.0.0.1:18789 root@<host>
Then open:
http://localhost:18789/
Docs:
https://docs.openclaw.ai/gateway/remote
https://docs.openclaw.ai/web/control-ui
Token auto-auth not delivered. Append your gateway token (from OPENCLAW_GATEWAY_TOKEN or gateway.auth.token) as a URL fragment with key `token` to authenticate.

4.2 配置安全上下文(SSH 端口转发)

由于环境没有图形界面,需要通过SSH隧道来连接,并手动把访问令牌添加到网页地址后面才能登录

在Windows的cmd中使用命令

bash 复制代码
ssh -N -L 18789:127.0.0.1:18789 root@192.168.168.130 -p 2233 

在浏览器访问,获取token信息 cat ~/.openclaw/openclaw.json|grep token

根据图片中的命令进行设备配对

bash 复制代码
# 查看已配对设备
openclaw devices list
# 批准请求
openclaw devices approve xxx

再次连接就可以在浏览器上进行对话了

4.3 飞书中配置

执行机器人发过来的命令批准访问即可

bash 复制代码
openclaw pairing approve feishu xxx

对话测试

相关推荐
未济4 天前
linux 配置环境变量
linux
傲世仙尊4 天前
目录即文件-Ext文件系统收尾篇
linux·c语言
虎头金猫4 天前
4K 视频总卡在公网带宽?用 N1 + OpenList 把网盘播放链路重新理顺
运维·服务器·网络·python·容器·beautifulsoup·pandas
_艾伦 耶格尔.4 天前
进程间通信
linux
AI职业加油站4 天前
AI智能体应用工程师证书:政策红利下的职业新风口
大数据·运维·人工智能·学习·职场发展
Liuqy-054 天前
Linux IO编程——静态库、动态库
linux
此冬歌咏4 天前
K8s 节点故障实战:优雅驱逐 31 秒,硬故障 331 秒,以及那个永远 Pending 的 Pod
运维·k8s
彧azz4 天前
Linux 环境下 Redis 学习总结:数据类型、持久化、锁、事务、主从与缓存问题
linux·redis·笔记·学习·面试
-梅4 天前
linux(8) 软硬链接
linux·运维·服务器
AIgorithmGEEK4 天前
[Linux]线程三部曲(上):一个执行流的诞生——从操作系统一路拆到 pthread_create
linux·线程·pid