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 Rendered
1# Install omnet Tailnet Lock on your Headscale server
2
3omnet adds the server half of Tailnet Lock to [Headscale](https://github.com/juanfont/headscale).
4With Tailnet Lock, your own devices decide which new devices may join, not the server. A stolen
5join key or a taken-over server can no longer quietly add a device that everyone else trusts.
6
7The Tailscale app on your devices already has the device half. It switches the Tailnet Lock
8controls on only when the server says it supports them. Plain Headscale does not, so the app
9greys them out. With omnet behind Headscale, the `tailscale lock` command works against your own
10server (tested with the v1.102 command-line client on Linux; the graphical apps were not tested). Nothing new is installed on the devices.
11
12This page gets you from nothing to a working lock. [`runbook.md`](runbook.md) is the careful,
13step-by-step version for turning it on over a tailnet you already use, and it is rehearsed by a
14test. The full engineering detail is in [`integration/headscale/README.md`](../integration/headscale/README.md).
15
16## What you need
17
18- A Linux **ARM64** machine to build on (the Omega compiler makes AArch64 Linux programs).
19- Go 1.26.5 or newer that may fetch toolchains (`GOTOOLCHAIN=auto`); Headscale builds with Go 1.27.3.
20- `git`, a POSIX shell, Python 3, and network access to the Go module proxy and to Headscale's
21 source for the first build.
22- Headscale **v0.29.6** (the patch is made for that exact release) and Tailscale clients at v1.102.x
23 (the tested version; test others before you rely on them).
24
25## Build
26
27From a checkout of this repository:
28
29```sh
30# The patched Headscale. Output: build/headscale
31GO=/path/to/go sh integration/headscale/build.sh
32
33# The Omega daemon that holds the lock's records. Output: build/tkad
34# (The first run builds the pinned Omega compiler from its seed, so it is slow once.)
35sh tools/build-tkad.sh
36
37# Optional checks before you install anything:
38GO=/path/to/go sh integration/headscale/leak-check.sh # the DERP memory fix (omnet#8) is in
39sh tools/test.sh # every Omega unit suite
40```
41
42## Try it on a throwaway tailnet first
43
44Two tests run a complete private tailnet inside a fresh, empty network namespace with the stock
45Tailscale client. They never touch your real tailnet, its sockets or your network interfaces.
46
47```sh
48GO=/path/to/go sh integration/e2e/build-clients.sh
49HEADSCALE_STOCK=1 HEADSCALE_OUTPUT=build/headscale-stock GO=/path/to/go sh integration/headscale/build.sh
50
51sh integration/e2e/run.sh --sudo-netns # the lock's full lifecycle
52sh integration/e2e/run.sh --sudo-netns --scenario runbook \
53 --stock-headscale "$PWD/build/headscale-stock" # runbook.md, step by step
54```
55
56Leave out `--sudo-netns` where your system lets ordinary users create user namespaces.
57
58## Run
59
60tkad and Headscale run as the **same user**, in the **same network namespace**, tkad first.
61
62```sh
63build/tkad /var/lib/headscale/omnet --init # first start only: creates the state directory, then keeps running
64build/tkad /var/lib/headscale/omnet # every later start (leave out --init)
65
66OMNET_TKAD_SOCKET=/var/lib/headscale/omnet/tkad.sock \
67OMNET_TKAD_ADMIN_USER_ID=<numeric Headscale user ID of the owner> \
68 build/headscale --config /etc/headscale/config.yaml serve
69```
70
71The owner is the Headscale user whose devices may start and switch off the lock. Pick the real
72number from `headscale users list`; there is no default. Setting only one of the two variables is
73an error.
74
75**Back up the Headscale database before the first start.** The first start adds two columns and a
76table. Stock Headscale then refuses that database until, on SQLite only,
77[`integration/headscale/downgrade.sql`](../integration/headscale/downgrade.sql) has removed them
78again (see the rollback in the runbook). There is no tested way back for PostgreSQL.
79
80## Turn the lock on
81
82Devices that joined before omnet have no lock key on record. They keep working, but the lock will
83not start (the server answers the owner's `init` with `409`) until each of them has signed in once more, from its console or
84a local-network session (see [`runbook.md`](runbook.md) step 3):
85
86```sh
87headscale preauthkeys create --user <ID of the device's own user> --expiration 1h # on the server
88tailscale up --force-reauth --auth-key=file:<key file> --login-server=<URL> <its current settings> # on the device
89```
90
91Then, on one of the devices that will approve new devices:
92
93```sh
94tailscale lock # shows this device's key: tlpub:...
95tailscale lock disablement-kdf <secret-hex> # turns each escape secret you made into its value
96tailscale lock init --confirm --gen-disablements=0 disablement:<value1> disablement:<value2> tlpub:<A> tlpub:<B>
97```
98
99Type secrets and join keys only in a shell whose history is off (`unset HISTFILE`), and close it
100afterwards. Make the escape secrets yourself beforehand (32 random bytes each, for example
101`head -c 32 /dev/urandom | od -An -v -tx1 | tr -d ' \n'`) and keep them somewhere safe that is not
102the server. Give `init` only their `disablement:` values, never the secrets. From then on a new
103device stays invisible to the others until an approving device runs `tailscale lock sign`.
104`tailscale lock disable disablement-secret:<secret>` from an owner device switches the lock off
105everywhere.
106
107## Before you rely on it
108
109- Tested: the protocol and stock-client behaviour in an isolated tailnet (the lifecycle test and the
110 runbook rehearsal, Linux command-line client v1.102.0), the Omega unit suites, and the DERP memory
111 fix. Not tested: packet
112 delivery, power loss, months of running, or a production security audit.
113- tkad and Headscale share one user account. Whoever controls the server can read the daemon's
114 state. Keep the approving keys on your devices and the escape secrets off the server, and keep a way
115 into the server that does not depend on the tailnet (console, or SSH on the local network).
116- The current daemon is sized for one tailnet of up to 64 devices and 128 lock changes. A change that
117 would not fit is refused, never half-written.
118- The patch is pinned to Headscale v0.29.6. Re-qualify it before you upgrade Headscale.