interplane.Get Omega
Read in your language

omnet

aien-dev/omnet

Brought by drakestapleton

branch main Branches Tags History

omnet / docs / install.md

118 lines · 6256 bytes Raw Blame History Source

Install omnet Tailnet Lock on your Headscale server

omnet adds the server half of Tailnet Lock to Headscale. With Tailnet Lock, your own devices decide which new devices may join, not the server. A stolen join key or a taken-over server can no longer quietly add a device that everyone else trusts.

The Tailscale app on your devices already has the device half. It switches the Tailnet Lock controls on only when the server says it supports them. Plain Headscale does not, so the app greys them out. With omnet behind Headscale, the tailscale lock command works against your own server (tested with the v1.102 command-line client on Linux; the graphical apps were not tested). Nothing new is installed on the devices.

This page gets you from nothing to a working lock. runbook.md is the careful, step-by-step version for turning it on over a tailnet you already use, and it is rehearsed by a test. The full engineering detail is in integration/headscale/README.md.

What you need

Build

From a checkout of this repository:

# The patched Headscale. Output: build/headscale
GO=/path/to/go sh integration/headscale/build.sh

# The Omega daemon that holds the lock's records. Output: build/tkad
# (The first run builds the pinned Omega compiler from its seed, so it is slow once.)
sh tools/build-tkad.sh

# Optional checks before you install anything:
GO=/path/to/go sh integration/headscale/leak-check.sh   # the DERP memory fix (omnet#8) is in
sh tools/test.sh                                         # every Omega unit suite

Try it on a throwaway tailnet first

Two tests run a complete private tailnet inside a fresh, empty network namespace with the stock Tailscale client. They never touch your real tailnet, its sockets or your network interfaces.

GO=/path/to/go sh integration/e2e/build-clients.sh
HEADSCALE_STOCK=1 HEADSCALE_OUTPUT=build/headscale-stock GO=/path/to/go sh integration/headscale/build.sh

sh integration/e2e/run.sh --sudo-netns                       # the lock's full lifecycle
sh integration/e2e/run.sh --sudo-netns --scenario runbook \
    --stock-headscale "$PWD/build/headscale-stock"           # runbook.md, step by step

Leave out --sudo-netns where your system lets ordinary users create user namespaces.

Run

tkad and Headscale run as the same user, in the same network namespace, tkad first.

build/tkad /var/lib/headscale/omnet --init     # first start only: creates the state directory, then keeps running
build/tkad /var/lib/headscale/omnet            # every later start (leave out --init)

OMNET_TKAD_SOCKET=/var/lib/headscale/omnet/tkad.sock \
OMNET_TKAD_ADMIN_USER_ID=<numeric Headscale user ID of the owner> \
  build/headscale --config /etc/headscale/config.yaml serve

The owner is the Headscale user whose devices may start and switch off the lock. Pick the real number from headscale users list; there is no default. Setting only one of the two variables is an error.

Back up the Headscale database before the first start. The first start adds two columns and a table. Stock Headscale then refuses that database until, on SQLite only, integration/headscale/downgrade.sql has removed them again (see the rollback in the runbook). There is no tested way back for PostgreSQL.

Turn the lock on

Devices that joined before omnet have no lock key on record. They keep working, but the lock will not start (the server answers the owner's init with 409) until each of them has signed in once more, from its console or a local-network session (see runbook.md step 3):

headscale preauthkeys create --user <ID of the device's own user> --expiration 1h   # on the server
tailscale up --force-reauth --auth-key=file:<key file> --login-server=<URL> <its current settings>   # on the device

Then, on one of the devices that will approve new devices:

tailscale lock                                  # shows this device's key: tlpub:...
tailscale lock disablement-kdf <secret-hex>     # turns each escape secret you made into its value
tailscale lock init --confirm --gen-disablements=0 disablement:<value1> disablement:<value2> tlpub:<A> tlpub:<B>

Type secrets and join keys only in a shell whose history is off (unset HISTFILE), and close it afterwards. Make the escape secrets yourself beforehand (32 random bytes each, for example head -c 32 /dev/urandom | od -An -v -tx1 | tr -d ' \n') and keep them somewhere safe that is not the server. Give init only their disablement: values, never the secrets. From then on a new device stays invisible to the others until an approving device runs tailscale lock sign. tailscale lock disable disablement-secret:<secret> from an owner device switches the lock off everywhere.

Before you rely on it