Skip to content

GatewayUse

Publish a devserver

Dial a devserver in with an access token, open it in a browser or Chan Desktop, and share it.

Publish a devserver

Publish one devserver to see the whole path work. It runs on a Linux host with chan installed, as in Install on the host.

  1. Create its token

    In the Tokens tab, choose New token, label it build-host, pick an expiry, and copy the token: it is shown once. The token is the devserver's identity: a new token makes a new devserver, at a new address.

  2. Start the devserver with it

    On the devserver's machine, with the token in the environment:

    $export CHAN_TUNNEL_TOKEN=chan_pat_... chan devserver start --port 8787 \ --tunnel-url https://proxy.example.com/v1/tunnel \ --tunnel-devserver-name build-host
  3. Check the connection

    The devserver's log names your username:

    $journalctl --user -u chan-devserver -f
    chan devserver: tunnel connected as user alice

    On the gateway, chan-gateway-admin tunnel ps lists it.

Details and limits
  • The systemd service keeps the token and the URL, so a later start, restart or join reuses them.
  • Pass the token in the environment, not as --tunnel-token: a flag is visible to every user in the process list.
  • --port 8787 keeps the devserver's local listener on its usual port, so Chan Desktop can still connect over ssh. Without it, a tunneled devserver picks a free port.
  • On macOS the launchd service cannot carry a tunnel: use chan devserver run with the same flags, or --service=chan.
  • A dropped tunnel dials again by itself.
  • To publish more machines, such as build hosts, GPU boxes or a VM per person, give each one its own token and run the same command on it.

Dial in through WireGuard

A devserver can reach a gateway that sits behind a WireGuard peer. chan runs the peer inside the devserver's own process: no network interface, no host routes, no root and no VPN client.

$chan devserver run \ --tunnel-url https://proxy.example.com/v1/tunnel \ --tunnel-wireguard /absolute/path/to/devserver.conf
  • The token still comes from CHAN_TUNNEL_TOKEN. CHAN_TUNNEL_WIREGUARD names the file in place of the flag.
  • The tunnel URL's destination must be inside the peer's AllowedIPs.
  • An http:// tunnel URL is accepted inside WireGuard, which pins the peer's key and encrypts the connection.
  • The file is the wg-quick subset that Chan Desktop reads. On Unix it must not be readable by the group or others: chmod 600 it.

Open it from a browser

Under My devservers, build-host is online. Click Open: the browser lands on the devserver's own origin, such as https://alice--3f9c2a7b1e04.p1.proxy.example.com/, on the Computers screen of Chan in a browser. The URL holds no token: the gateway's OAuth2 sign-in is the key.

Connect Chan Desktop

Chan Desktop adds your self-hosted gateway by its URL and signs in through the browser; Connect to a gateway has the steps. The gateway carries the connection, with no connect script or control terminal, and cs tunnel works through it.

Details and limits
  • A desktop gives back a sign-in token it does not keep, as after a cancelled sign-in. The token's audit reads revoked_via_desktop.
  • A token given back after it was used also disconnects that account's tunnels and gateway sessions.

Share it

A share gives another account the whole devserver: its terminals, processes, files and workspaces. That is a shell account on the machine, so share only with people you would give one.

  1. Let them in

    On the gateway, as root, with the admin credentials loaded:

    #chan-gateway-admin user create --email friend@example.com chan-gateway-admin flag grant oauth_login friend@example.com
  2. Add the share

    In Devservers, click Share on build-host, enter their email, and click Add. The share reads pending sign-in until they sign in with that verified email, then active.

  3. Send them to it

    In Chan Desktop, your devserver is on their Computers screen once they add the gateway. For a browser, Copy link on build-host's row copies its gateway address, which asks for sign-in and opens only for you and the people it is shared with.

To take access away, click Revoke on the share. Their sessions on that devserver end.

Shares are the owner's, on the account page; the admin CLI has no share command. As the operator you can:

You want toRun
List devservers shared with them under Shared with mechan-gateway-admin flag grant share_workspaces friend@example.com
See who is in alice's devserverschan-gateway-admin session tenant ps --owner alice
End one person's open devserver sessionschan-gateway-admin session tenant revoke-subject friend@example.com
Details and limits
  • Copy link on your own row shows only while the devserver is online.
  • A row under Shared with me does not say whether the devserver is online; while it is offline, its link answers not found.
  • The first time they open a shared devserver, Chan Desktop asks them to grant it native access.
  • Revoking a share ends their access through chan. It cannot undo changes they made on the host or recover secrets they copied.
  • Ending someone's sessions leaves their shares in place; they can open the devserver again.

Next