Ejecutar OpenClaw.app con un Gateway remoto
OpenClaw.app usa un túnel SSH para conectarse a un gateway remoto. Esta guía te muestra cómo configurarlo.
Visión general
flowchart TB
subgraph Client["Máquina cliente"]
direction TB
A["OpenClaw.app"]
B["ws://127.0.0.1:18789\n(puerto local)"]
T["Túnel SSH"]
A --> B
B --> T
end
subgraph Remote["Máquina remota"]
direction TB
C["Gateway WebSocket"]
D["ws://127.0.0.1:18789"]
C --> D
end
T --> C
Configuración rápida
Paso 1: Agregar la configuración SSH
Edita ~/.ssh/config y agrega:
Host remote-gateway
HostName <REMOTE_IP> # ej., 172.27.187.184
User <REMOTE_USER> # ej., jefferson
LocalForward 18789 127.0.0.1:18789
IdentityFile ~/.ssh/id_rsa
Reemplaza <REMOTE_IP> y <REMOTE_USER> con tus valores.
Paso 2: Copiar la clave SSH
Copia tu clave pública a la máquina remota (ingresa la contraseña una vez):
ssh-copy-id -i ~/.ssh/id_rsa <REMOTE_USER>@<REMOTE_IP>
Paso 3: Configurar el token del Gateway
launchctl setenv OPENCLAW_GATEWAY_TOKEN "<your-token>"
Paso 4: Iniciar el túnel SSH
ssh -N remote-gateway &
Paso 5: Reiniciar OpenClaw.app
# Cierra OpenClaw.app (⌘Q), luego vuelve a abrirla:
open /path/to/OpenClaw.app
La app ahora se conectará al gateway remoto a través del túnel SSH.
Inicio automático del túnel al iniciar sesión
Para que el túnel SSH se inicie automáticamente cuando inicias sesión, crea un Launch Agent.
Crear el archivo PLIST
Guárdalo como ~/Library/LaunchAgents/ai.openclaw.ssh-tunnel.plist:
<?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>
<string>ai.openclaw.ssh-tunnel</string>
<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>
Cargar el Launch Agent
launchctl bootstrap gui/$UID ~/Library/LaunchAgents/ai.openclaw.ssh-tunnel.plist
El túnel ahora:
- Se iniciará automáticamente al iniciar sesión
- Se reiniciará si se cae
- Se mantendrá ejecutándose en segundo plano
Nota heredada: elimina cualquier LaunchAgent com.openclaw.ssh-tunnel sobrante si existe.
Solución de problemas
Verificar si el túnel está ejecutándose:
ps aux | grep "ssh -N remote-gateway" | grep -v grep
lsof -i :18789
Reiniciar el túnel:
launchctl kickstart -k gui/$UID/ai.openclaw.ssh-tunnel
Detener el túnel:
launchctl bootout gui/$UID/ai.openclaw.ssh-tunnel
Cómo funciona
| Componente | Qué hace |
|---|---|
LocalForward 18789 127.0.0.1:18789 | Reenvía el puerto local 18789 al puerto remoto 18789 |
ssh -N | SSH sin ejecutar comandos remotos (solo reenvío de puertos) |
KeepAlive | Reinicia automáticamente el túnel si se cae |
RunAtLoad | Inicia el túnel cuando se carga el agente |
OpenClaw.app se conecta a ws://127.0.0.1:18789 en tu máquina cliente. El túnel SSH reenvía esa conexión al puerto 18789 en la máquina remota donde se ejecuta el Gateway.