在 macOS VM 中运行 OpenClaw(沙箱化)
大多数用户的推荐选择
- 小型 Linux VPS 用于全天候网关运行,成本低。参阅 VPS 托管。
- 专用硬件(Mac mini 或 Linux 主机),如果你想要完全控制和家庭 IP 进行浏览器自动化。许多网站会拦截数据中心 IP,本地浏览通常效果更好。
- 混合方案: 网关跑在便宜的 VPS 上,Mac 作为节点在需要浏览器/UI 自动化时连入。参阅节点和网关远程模式。
当你确实需要 macOS 专属功能(iMessage/BlueBubbles)或想和日常使用的 Mac 严格隔离时,才使用 macOS VM。
macOS VM 选项
在 Apple Silicon Mac 上运行本地 VM(Lume)
使用 Lume 在你现有的 Apple Silicon Mac 上以沙箱化的 macOS VM 运行 OpenClaw。
这能带来:
- 完全隔离的 macOS 环境(宿主机保持干净)
- 通过 BlueBubbles 支持 iMessage(Linux/Windows 上不可能实现)
- 通过克隆 VM 实现即时重置
- 无需额外硬件或云费用
托管 Mac 提供商(云端)
如果你想在云端使用 macOS,托管 Mac 提供商也可以:
- MacStadium(托管 Mac)
- 其他托管 Mac 供应商也可以;按照他们的 VM + SSH 文档操作
获得对 macOS VM 的 SSH 访问后,跳到下方第 6 步继续。
快速上手(Lume,有经验的用户)
- 安装 Lume
lume create openclaw --os macos --ipsw latest- 完成设置助理,启用远程登录(SSH)
lume run openclaw --no-display- SSH 进入,安装 OpenClaw,配置渠道
- 完成
前置条件(Lume)
- Apple Silicon Mac(M1/M2/M3/M4)
- 宿主机运行 macOS Sequoia 或更新版本
- 每个 VM 约需 60 GB 空闲磁盘空间
- 约 20 分钟时间
1) 安装 Lume
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/lume/scripts/install.sh)"
如果 ~/.local/bin 不在你的 PATH 中:
echo 'export PATH="$PATH:$HOME/.local/bin"' >> ~/.zshrc && source ~/.zshrc
验证:
lume --version
文档:Lume 安装
2) 创建 macOS VM
lume create openclaw --os macos --ipsw latest
这会下载 macOS 并创建 VM。VNC 窗口会自动打开。
注意:下载时间取决于你的网络速度。
3) 完成设置助理
在 VNC 窗口中:
- 选择语言和地区
- 跳过 Apple ID(如果之后需要 iMessage 则登录)
- 创建用户账号(记住用户名和密码)
- 跳过所有可选功能
设置完成后,启用 SSH:
- 打开 System Settings → General → Sharing
- 启用 “Remote Login”
4) 获取 VM 的 IP 地址
lume get openclaw
找到 IP 地址(通常是 192.168.64.x)。
5) SSH 进入 VM
ssh [email protected]
将 youruser 替换为你创建的账号,IP 替换为你 VM 的 IP。
6) 安装 OpenClaw
在 VM 中:
npm install -g openclaw@latest
openclaw onboard --install-daemon
按照引导提示设置你的模型提供商(Anthropic、OpenAI 等)。
7) 配置渠道
编辑配置文件:
nano ~/.openclaw/openclaw.json
添加你的渠道:
{
"channels": {
"whatsapp": {
"dmPolicy": "allowlist",
"allowFrom": ["+15551234567"]
},
"telegram": {
"botToken": "YOUR_BOT_TOKEN"
}
}
}
然后登录 WhatsApp(扫码):
openclaw channels login
8) 无头运行 VM
停止 VM 并以无显示模式重启:
lume stop openclaw
lume run openclaw --no-display
VM 在后台运行。OpenClaw 的 daemon 会保持网关运行。
检查状态:
ssh [email protected] "openclaw status"
额外福利:iMessage 集成
这是在 macOS 上运行的杀手级特性。使用 BlueBubbles 将 iMessage 接入 OpenClaw。
在 VM 中:
- 从 bluebubbles.app 下载 BlueBubbles
- 用你的 Apple ID 登录
- 启用 Web API 并设置密码
- 将 BlueBubbles webhook 指向你的网关(例如:
https://your-gateway-host:3000/bluebubbles-webhook?password=<password>)
在 OpenClaw 配置中添加:
{
"channels": {
"bluebubbles": {
"serverUrl": "http://localhost:1234",
"password": "your-api-password",
"webhookPath": "/bluebubbles-webhook"
}
}
}
重启网关,你的 Agent 就可以收发 iMessage 了。
完整设置详情:BlueBubbles 渠道
保存黄金镜像
在进一步自定义前,快照你的干净状态:
lume stop openclaw
lume clone openclaw openclaw-golden
随时重置:
lume stop openclaw && lume delete openclaw
lume clone openclaw-golden openclaw
lume run openclaw --no-display
全天候运行
保持 VM 运行的方法:
- Mac 保持接通电源
- 在 System Settings → Energy Saver 中禁用睡眠
- 需要时使用
caffeinate
要实现真正的全天候运行,考虑使用专用 Mac mini 或小型 VPS。参阅 VPS 托管。
排错
| 问题 | 解决方案 |
|---|---|
| 无法 SSH 进入 VM | 检查 VM 的 System Settings 中 “Remote Login” 是否已启用 |
| VM IP 未显示 | 等 VM 完全启动后再运行 lume get openclaw |
| Lume 命令未找到 | 将 ~/.local/bin 添加到 PATH |
| WhatsApp 二维码无法扫描 | 确认你在 VM(不是宿主机)中运行 openclaw channels login |
相关文档
- VPS 托管
- 节点
- 网关远程模式
- BlueBubbles 渠道
- Lume 快速入门
- Lume CLI 参考
- 无人值守 VM 配置(高级)
- Docker 沙箱(另一种隔离方案)