Windows(WSL2)
在 Windows 上通过 WSL2 运行 OpenClaw
在 Windows 上运行 OpenClaw,推荐 通过 WSL2(建议使用 Ubuntu)。CLI + Gateway 运行在 Linux 环境里,这能保持运行时一致,并让工具链兼容性显著更好(Node/Bun/pnpm、Linux 二进制、skills 等)。直接在原生 Windows 上跑可能更麻烦;而 WSL2 能提供完整的 Linux 体验——一条命令即可安装:wsl --install。
原生 Windows 伴侣应用在规划中。
安装(WSL2)
Gateway
Gateway 服务安装(CLI)
在 WSL2 内:
openclaw onboard --install-daemon
或:
openclaw gateway install
或:
openclaw configure
出现提示时选择 Gateway service。
修复/迁移:
openclaw doctor
高级:通过 LAN 暴露 WSL 服务(portproxy)
WSL 有独立的虚拟网络。如果需要让另一台机器访问 WSL 内 运行的服务(SSH、本地 TTS 服务或 Gateway),你必须把 Windows 端口转发到当前的 WSL IP。WSL IP 会在重启后变化,因此可能需要刷新转发规则。
示例(以管理员身份运行 PowerShell):
$Distro = "Ubuntu-24.04"
$ListenPort = 2222
$TargetPort = 22
$WslIp = (wsl -d $Distro -- hostname -I).Trim().Split(" ")[0]
if (-not $WslIp) { throw "WSL IP not found." }
netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=$ListenPort `
connectaddress=$WslIp connectport=$TargetPort放行 Windows 防火墙(只需一次):
New-NetFirewallRule -DisplayName "WSL SSH $ListenPort" -Direction Inbound ` -Protocol TCP -LocalPort $ListenPort -Action Allow
在 WSL 重启后刷新 portproxy:
netsh interface portproxy delete v4tov4 listenport=$ListenPort listenaddress=0.0.0.0 | Out-Null netsh interface portproxy add v4tov4 listenport=$ListenPort listenaddress=0.0.0.0 ` connectaddress=$WslIp connectport=$TargetPort | Out-Null
说明:
- 从另一台机器 SSH 时,目标是 Windows 主机 IP(例如:ssh user@windows-host -p 2222)。
- 远程节点必须指向一个 可达 的 Gateway URL(不是 127.0.0.1);用 openclaw status --all 检查。
- listenaddress=0.0.0.0 表示对 LAN 开放;127.0.0.1 则只本机可访问。
- 如果想自动化,可以注册一个计划任务,在登录时运行刷新步骤。
WSL2 安装步骤(一步步)
按下面步骤安装 WSL2 + Ubuntu,并在 WSL 中完成 OpenClaw 安装。
1)安装 WSL2 + Ubuntu
打开 PowerShell(管理员):
wsl --install wsl --list --online wsl --install -d Ubuntu-24.04
如果系统提示需要重启,请按提示重启。
2)启用 systemd(Gateway service 安装需要)
在 WSL 终端中:
sudo tee /etc/wsl.conf >/dev/null <<'EOF' [boot] systemd=true EOF
然后在 PowerShell 中:
wsl --shutdown
重新打开 Ubuntu 并验证:
systemctl --user status
3)在 WSL 内安装 OpenClaw
在 WSL 内按 Linux 的 Getting Started 流程操作:
git clone https://github.com/openclaw/openclaw.git cd openclaw pnpm install pnpm ui:build # First run will auto-install UI dependencies pnpm build openclaw onboard
完整指南:Getting Started
Windows 伴侣应用
目前还没有 Windows 伴侣应用。如果你愿意贡献,欢迎一起来做。