2026-01-05 22:13:21 +01:00
---
2026-01-30 03:15:10 +01:00
summary: "SSH tunnel setup for OpenClaw.app connecting to a remote gateway"
2026-01-05 22:13:21 +01:00
read_when: "Connecting the macOS app to a remote gateway over SSH"
2026-01-31 16:04:03 -05:00
title: "Remote Gateway Setup"
2026-01-05 22:13:21 +01:00
---
2026-01-30 03:15:10 +01:00
# Running OpenClaw.app with a Remote Gateway
2026-01-03 23:04:55 -06:00
2026-01-30 03:15:10 +01:00
OpenClaw.app uses SSH tunneling to connect to a remote gateway. This guide shows you how to set it up.
2026-01-03 23:04:55 -06:00
## Overview
2026-02-09 20:57:27 +05:30
```mermaid
flowchart TB
subgraph Client["Client Machine"]
direction TB
A["OpenClaw.app"]
B["ws://127.0.0.1:18789\n(local port)"]
T["SSH Tunnel"]
A --> B
B --> T
end
subgraph Remote["Remote Machine"]
direction TB
C["Gateway WebSocket"]
D["ws://127.0.0.1:18789"]
C --> D
end
T --> C
2026-01-03 23:04:55 -06:00
```
## Quick Setup
### Step 1: Add SSH Config
Edit `~/.ssh/config` and add:
```ssh
Host remote-gateway
HostName < REMOTE_IP > # e.g., 172.27.187.184
User < REMOTE_USER > # e.g., jefferson
LocalForward 18789 127.0.0.1:18789
IdentityFile ~/.ssh/id_rsa
```
Replace `<REMOTE_IP>` and `<REMOTE_USER>` with your values.
### Step 2: Copy SSH Key
Copy your public key to the remote machine (enter password once):
```bash
ssh-copy-id -i ~/.ssh/id_rsa < REMOTE_USER > @< REMOTE_IP >
```
### Step 3: Set Gateway Token
```bash
2026-01-30 03:15:10 +01:00
launchctl setenv OPENCLAW_GATEWAY_TOKEN "< your-token > "
2026-01-03 23:04:55 -06:00
```
### Step 4: Start SSH Tunnel
```bash
ssh -N remote-gateway &
```
2026-01-30 03:15:10 +01:00
### Step 5: Restart OpenClaw.app
2026-01-03 23:04:55 -06:00
```bash
2026-01-30 03:15:10 +01:00
# Quit OpenClaw.app (⌘Q), then reopen:
open /path/to/OpenClaw.app
2026-01-03 23:04:55 -06:00
```
The app will now connect to the remote gateway through the SSH tunnel.
---
## Auto-Start Tunnel on Login
To have the SSH tunnel start automatically when you log in, create a Launch Agent.
### Create the PLIST file
2026-01-27 14:46:27 -06:00
Save this as `~/Library/LaunchAgents/bot.molt.ssh-tunnel.plist` :
2026-01-03 23:04:55 -06:00
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
< plist version = "1.0" >
< dict >
< key > Label< / key >
2026-01-27 14:46:27 -06:00
< string > bot.molt.ssh-tunnel< / string >
2026-01-03 23:04:55 -06:00
< key > ProgramArguments< / key >
< array >
< string > /usr/bin/ssh< / string >
< string > -N< / string >
< string > remote-gateway< / string >
< / array >
< key > KeepAlive< / key >
< true / >
< key > RunAtLoad< / key >
< true / >
< / dict >
< / plist >
```
### Load the Launch Agent
```bash
2026-01-27 14:46:27 -06:00
launchctl bootstrap gui/$UID ~/Library/LaunchAgents/bot.molt.ssh-tunnel.plist
2026-01-03 23:04:55 -06:00
```
The tunnel will now:
2026-01-31 21:13:13 +09:00
2026-01-03 23:04:55 -06:00
- Start automatically when you log in
- Restart if it crashes
- Keep running in the background
2026-01-30 03:15:10 +01:00
Legacy note: remove any leftover `com.openclaw.ssh-tunnel` LaunchAgent if present.
2026-01-27 14:46:27 -06:00
2026-01-03 23:04:55 -06:00
---
## Troubleshooting
**Check if tunnel is running:**
```bash
ps aux | grep "ssh -N remote-gateway" | grep -v grep
lsof -i :18789
```
**Restart the tunnel:**
```bash
2026-01-27 14:46:27 -06:00
launchctl kickstart -k gui/$UID/bot.molt.ssh-tunnel
2026-01-03 23:04:55 -06:00
```
**Stop the tunnel:**
```bash
2026-01-27 14:46:27 -06:00
launchctl bootout gui/$UID/bot.molt.ssh-tunnel
2026-01-03 23:04:55 -06:00
```
---
## How It Works
2026-01-31 21:13:13 +09:00
| Component | What It Does |
| ------------------------------------ | ------------------------------------------------------------ |
| `LocalForward 18789 127.0.0.1:18789` | Forwards local port 18789 to remote port 18789 |
| `ssh -N` | SSH without executing remote commands (just port forwarding) |
| `KeepAlive` | Automatically restarts tunnel if it crashes |
| `RunAtLoad` | Starts tunnel when the agent loads |
2026-01-03 23:04:55 -06:00
2026-01-30 03:15:10 +01:00
OpenClaw.app connects to `ws://127.0.0.1:18789` on your client machine. The SSH tunnel forwards that connection to port 18789 on the remote machine where the Gateway is running.