skip to content

How do you reach an OpenClaw Gateway on a remote server from your laptop without opening its port to the internet?

level: middleimportance: must knowfreq 16%

answer

  1. keep the server side on loopback
  2. forward one local port over SSH
  3. a tailnet-only HTTPS proxy
  4. identity headers cover only part of the API
  5. explicit URLs carry no saved credentials

basics

~20 s

Keep the Gateway on loopback and bring the port to you: an SSH tunnel forwarding 127.0.0.1:18789, or OpenClaw-managed Tailscale Serve, which proxies tailnet-only HTTPS to the loopback Gateway. Funnel and wide binds widen exposure and lean harder on auth.

solid answer

~40 s

The pattern is: the Gateway never listens publicly; something you already trust carries the traffic. The universal fallback is `ssh -N -L 18789:127.0.0.1:18789 user@host`, after which the CLI and Control UI use `ws://127.0.0.1:18789` as if local; `gateway.remote.url` and `gateway.remote.token` (or `sshTarget`) make it the CLI's default. The nicer option is `gateway.tailscale.mode: "serve"` with `gateway.bind: "loopback"`: OpenClaw drives Tailscale Serve for tailnet-only HTTPS, and with `allowTailscale` defaulting on for Serve, the Control UI WebSocket can authenticate by tailnet identity. HTTP APIs still need the token. `"funnel"` is public and only starts with password auth. Binding `"tailnet"` directly works too, but over plain `ws://`.

code

json · 7 lines
json
{
  "gateway": {
    "bind": "loopback",
    "tailscale": { "mode": "serve" },
    "auth": { "mode": "token", "token": "replace-with-a-long-random-token" }
  }
}

go deeper

for a junior

Know the two safe routes: an SSH tunnel to 127.0.0.1:18789, or Tailscale Serve with the Gateway left on loopback.

for a middle

Explain how Serve authenticates the Control UI through tailnet identity, which endpoints still need the token, and why gateway.remote.token is a client setting.

for a senior

Spot the traps: Funnel's public exposure and password requirement, tokenless Serve on a host running untrusted code, and --url ignoring saved credentials.

for a principal

Pick one remote-access path for everyone using the install and write down why: SSH for zero new dependencies, Serve for stable HTTPS and phones.

## The principle OpenClaw's own remote-access guidance starts from one rule: **keep `gateway.bind: "loopback"` on the server and move the traffic, not the listener**. The Gateway on port `18789` holds operator-level control of your channels and tools, so it should never be the first thing a stranger's packet touches. Two mechanisms cover nearly every personal or small-team setup; a direct tailnet bind and Funnel are the alternatives, each with more exposure. | Pattern | Gateway bind | Transport | Auth that applies | |---|---|---|---| | SSH tunnel | `loopback` | SSH, then `ws://127.0.0.1:18789` locally | Gateway token or password | | Tailscale Serve (managed) | `loopback` (required) | HTTPS on your MagicDNS name, tailnet only | Tailnet identity for the Control UI WebSocket; token for HTTP APIs | | Direct tailnet bind | `tailnet` | Plain `ws://<tailscale-ip>:18789` | Gateway token or password | | Tailscale Funnel | `loopback` | Public HTTPS | Password mode only | ## SSH tunnel: works from anywhere ```bash ssh -N -L 18789:127.0.0.1:18789 user@gateway-host ``` The first port is on your laptop, the second is the Gateway's port on the server. With the tunnel up, `openclaw health`, `openclaw status --deep` and the Control UI at `http://127.0.0.1:18789/` reach the remote Gateway as though it were local. Points that catch people: - **Explicit `--url` carries no saved credentials.** `openclaw gateway probe --url ws://127.0.0.1:18789` never falls back to config or environment credentials; pass `--token` or `--password`. - **Persist the target** with `gateway.mode: "remote"`, `gateway.remote.url: "ws://127.0.0.1:18789"` and `gateway.remote.token`. Setting `gateway.remote.sshTarget` lets the CLI open and own the tunnel itself; `gateway.remote.transport: "direct"` keeps a manually managed forward. - **`gateway.remote.token` is a client credential.** It is what the CLI sends; it does not protect the server. - The server's SSH daemon must allow local forwarding, and the cloud firewall should allow SSH and nothing on `18789`. ## Tailscale Serve: HTTPS on the tailnet With `gateway.tailscale.mode: "serve"`, OpenClaw drives Tailscale Serve itself: 1. The Gateway stays on `127.0.0.1`; startup **refuses** Serve or Funnel with any non-loopback bind. 2. Tailscale provides HTTPS and routing; you open `https://<magicdns>/`. 3. `gateway.auth.allowTailscale` defaults to `true` for Serve (unless the mode is password or trusted-proxy), so the Control UI WebSocket can authenticate with the `tailscale-user-login` header, which OpenClaw verifies by asking the local Tailscale daemon (`tailscale whois`) about the forwarded address. The tokenless path is deliberately narrow. It applies only on OpenClaw's dedicated managed-Serve listener, only to the Control UI WebSocket (and avatar reads), not to `/v1/*`, `/tools/invoke` or `/api/channels/*`. It does not skip browser device identity, and node devices still pair normally. It also assumes the Gateway host is trusted: if untrusted code may run there, set `allowTailscale: false` and require the token. ## What not to reach for - **`"funnel"`** publishes the Gateway to the internet. OpenClaw refuses to start it unless `gateway.auth.mode` is `"password"`, and the audit reports `gateway.tailscale_funnel` as critical. - **A direct `"tailnet"` bind** is fine on a tailnet you control, but traffic is plain `ws://`; Serve gives you HTTPS. - **Opening `18789` in the firewall** to use the dashboard from a café is the mistake this whole page avoids. ## Making the remote client trustworthy too The client side has its own checks, and they matter once the Gateway is somewhere else: - **Host keys.** For the client-managed tunnel, the remote-access guide documents host-key verification as strict by default (`gateway.remote.sshHostKeyPolicy: "strict"`, which needs an already trusted host key); `"openssh"` delegates to your effective OpenSSH config. - **TLS pinning.** For a `wss://` endpoint, `gateway.remote.tlsFingerprint` pins the certificate so a look-alike endpoint cannot collect your token. - **Plain `ws://`** is accepted only for loopback, private IP literals, `.local` and Tailnet `*.ts.net` names; other private names need TLS or an explicit break-glass environment variable on the client. ## Choosing For one person, either works; SSH needs nothing new installed, Serve gives a stable HTTPS URL and phone access. Whichever you pick, run `openclaw security audit --deep` afterwards: the live probe confirms the Gateway answers where you expect and nowhere else.

  • With OpenClaw's managed Tailscale Serve, why does `curl` to `/v1/chat/completions` still need the token?
    Tailscale identity-header auth applies only to the Control UI WebSocket surface (plus avatar reads) on the managed Serve listener. HTTP API endpoints such as `/v1/*`, `/tools/invoke` and `/api/channels/*` always follow the Gateway's configured HTTP auth mode, so callers send the shared token or password.
  • When should you set `gateway.auth.allowTailscale` to false on a Serve setup?
    When untrusted code might run on the Gateway host. Tokenless Serve auth assumes the host itself is trusted; it is not protection against hostile same-host processes. Turning it off makes every Control UI connection present the shared token or password as well.

  • Open port 18789 in the cloud firewall to use the dashboard remotely.
  • Tailscale Serve needs the Gateway bound to its Tailnet IP.
  • With Serve, the tailnet identity replaces the token for every endpoint.
  • Funnel is just Serve with a nicer URL.
  • An explicit --url reuses the token from config automatically.