Installing openclaw on WSL (Non-Root User)
This guide focuses on installing and configuring `openclaw` for a non-root user within a WSL environment.
**Example Configuration: Please replace these with your own system details**
* `<WIN_BAT_PATH>`: The path to the `.bat` file that needs to run at boot; e.g., `E:\WSL\ubuntu\scripts\update_wsl_ports_by_admin.bat`
* `<WIN_IP>`: Your Windows machine's IP address.
---
## Installing openclaw
* **Steps (Execute in the WSL terminal):**
```bash
cd ~/
# Install openclaw (this will also install Node.js)
curl -fsSL https://openclaw.ai/install-cli.sh | bash
# Add openclaw to your PATH
echo 'export PATH="$HOME/.openclaw/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
# Confirm the openclaw version
openclaw --version
# Setup and install the daemon
openclaw onboard --install-daemon
# (Note: For specific openclaw configurations, please refer to the official documentation or AI assistants)
```
* **Default Web Interface:** `http://localhost:18789`
## Enabling openclaw to Run on WSL Startup
* **Install Daemon and Enable Persistence:**
```bash
# Setup and install daemon
openclaw onboard --install-daemon
# Enable user lingering to allow the daemon to start at boot without an active session
loginctl enable-linger $USER
```
## Enabling Local Area Network (LAN) Access
To allow other devices on your network to access the dashboard, run the following commands:
```bash
# Set the gateway to bind to the LAN
openclaw config set gateway.bind lan
# Enable insecure access and disable device authentication for easier LAN setup
openclaw config set gateway.controlUi.allowInsecure true
openclaw config set gateway.controlUi.dangerouslyDisableDeviceAuth true
# Add the Windows IP to allowed origins (Crucial) [Replace <WIN_IP> with your actual Windows IP]
openclaw config set gateway.controlUi.allowedOrigins '["http://<WIN_IP>:18789", "http://localhost:18789", "http://127.0.0.1:18789"]'
# Restart the Gateway to apply changes
openclaw gateway restart
```
## Local Network Connectivity and Firewall Port Forwarding
This step ensures that other computers can access WSL via your Windows IP (`<WIN_IP>`).
### 1. Open Firewall (PowerShell Administrator) - Run Once Only!
```bat
New-NetFirewallRule -DisplayName "WSL openclaw Port 18789" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 18789
```
### 2. Update the [WSL to Windows] Port Forwarding Batch File
To handle the dynamic nature of the WSL IP address, add the following lines to the end of your existing batch file (e.g., located at `<WIN_BAT_PATH>\update_wsl_ports_by_admin.bat`).
*[Refer to the "WSL Auto-Start and Persistent Background Execution (via SSH)"]*
```bat
echo ====== Processing openclaw dashboard web 18789
:: Delete old portproxy (ignore errors) -> Add port forwarding (Listen on all Windows interfaces, forward to WSL)
netsh interface portproxy delete v4tov4 listenport=18789 >nul 2>&1
netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=18789 connectaddress=%WSL_IP% connectport=18789
if %errorlevel% equ 0 (
:: Replace <WIN_IP> with your actual Windows IP
echo V Port forwarding: Done! Internal network connection is available: <WIN_IP>:18789
) else (
echo X Port forwarding: Failed. Please run this bat file as a system administrator.
)
echo.
echo Current settings:
netsh interface portproxy show v4tov4 | findstr 18789
echo.
```
## How to Connect?
* Open your browser and go to: `http://<WIN_IP>:18789`
## Useful Post-Installation Commands
- `openclaw --version` $\rightarrow$ Verify installation.
- `openclaw onboard` $\rightarrow$ Rerun the initial setup.
- `openclaw gateway status` $\rightarrow$ Check the status of the gateway.
- `openclaw doctor` $\rightarrow$ Diagnose potential issues.
## Reference
WSL Auto-Start and Persistent Background Execution (via SSH)
Comments
Post a Comment