kvbox.cloud
Self-host

Join a control plane

Put a host behind api.kvbox.sh or your own control plane.

A host alone is complete, but the CLI has to be on it. A control plane (api.kvbox.sh, or your own) lets you log in from anywhere, places new boxes on the host with the most room, and lets several hosts show up as one. See Install for logging in.

An admin on the control plane mints a one-time token for the host; you run its command on the host:

kvbox-server join https://api.kvbox.sh --token <token> [--advertise <public host or ip>] [--name <name>] [--country <country>]
kvbox-server leave       # forget the control plane; the port closes

Both restart the daemon for you when it is running (boxes are not affected).

What join does

  • makes the host's TLS certificate under ~/.kvbox/tls; the control plane pins its fingerprint
  • sends the address the control plane reaches the host at: the default-route address, or --advertise (a private address has to be named explicitly)
  • sends where the host is with --country (a name or a code: romania, US), so kvbox new --country can place boxes there; an admin sets or changes it later with PATCH /admin/hosts/<name> {"country": "RO"}
  • keeps the secret it gets back in config.json

From its next start the server also answers on HTTPS port 7777, to that control plane. Every call has to carry the secret. The control plane's users become owners <user>@<control plane> on the host, kept apart from the host owner's own boxes. Each box also gets its own public SSH port on the host, which kvbox connect uses from outside.

Within a minute the host also has an encrypted tunnel (WireGuard, interface kvmesh) to every other host of the control plane, on UDP port 51821: a link between boxes on two hosts rides it, each box with its own address. Keep UDP 51821 open between the hosts (a cloud firewall or security group included): a host can name the others in kvbox-server net status while no packet gets through, and a link across hosts then connects to nothing. A host behind a relay needs nothing more, the relay passes 51821 down.

Every 30 seconds the control plane polls its hosts and keeps what each one lists, which is what ls answers from (a command run through the control plane shows at once). A host the poller has not reached for a minute shows its boxes in ls with status unknown rather than hiding them, and its usage ledger is pulled in the same sweep.

On this page