Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omnet/blob/main/docs/runbook.md # omnet aien-dev/omnet Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omnet / docs / runbook.md` 135 lines ยท 8103 bytes Raw Blame History Source # Runbook: turn on Tailnet Lock over a tailnet you already use Every step below is rehearsed, in this order, by ``` sh integration/e2e/run.sh --sudo-netns --scenario runbook --stock-headscale "$PWD/build/headscale-stock" ``` on a private tailnet in an empty network namespace, with the same shape as a small home tailnet: two approving devices (A and B, `signer-a` and `signer-b` in the test), a server node, a phone, and one device owned by another user. The test names its checks after the steps. Run it on the exact build you will install, and stop if any check fails. What the rehearsal does not cover: every device in it is the Linux command-line client v1.102.0. The macOS app, the phone app, tagged devices and devices with extra settings (routes, exit node, Tailscale SSH) are not in it; step 3 says what to check for them by hand. Words used here: an approving device holds a lock key that may sign new devices. An **escape secret** (Tailscale calls it a disablement secret) switches the lock off for the whole tailnet. Its value is a one-way fingerprint of it that goes into the lock when it starts. ## 0. Before the change window - Keep a way into the Headscale server and into every machine you will sign in again in step 3 that does not use the tailnet: its console, or SSH over the local network. Test each one now. An SSH session that runs over the tailnet is not a way back in. - Make two escape secrets on an approving device and store each in a different safe place, never on the Headscale server. Do this, and every later command that contains a secret or a join key, in a shell whose history is off (`unset HISTFILE` in bash or zsh), and close that terminal afterwards; a secret on a command line is also briefly visible in the process list. Secret: `head -c 32 /dev/urandom | od -An -v -tx1 | tr -d ' \n'`. Turn each into its value with `tailscale lock disablement-kdf ` and write the values down (they are not secret). - On A and B run `tailscale lock` and note each `tlpub:` key. - Note the owner's numeric user ID (`headscale users list`) and every device (`headscale nodes list`), including devices that are rarely online. ## 1. Back up and install (rehearsal: `stock-tailnet-running-and-database-backed-up`) - Stop Headscale. Copy the database file and its `-wal` and `-shm` files, plus the config, to a dated backup. Keep the stock `headscale` binary. - Install `tkad` and the patched `headscale`. ## 2. Start omnet with the lock still off (rehearsal: `patched-headscale-adopts-existing-database-without-lock`) Start tkad, then the patched Headscale with `OMNET_TKAD_SOCKET` and `OMNET_TKAD_ADMIN_USER_ID`. On this first start run `tkad --init`: it creates the state directory and then keeps running as the daemon. Leave out `--init` on every later start. Every device reconnects and sees every other device. The lock is not on yet. ## 3. Every device signs in once more (rehearsal: `init-refused-until-every-node-re-registers`, `every-node-re-registered-same-identity`) Devices from before omnet have no lock key on record, so the owner's `tailscale lock init` is refused with `409` (any other user's devices get `403` from the daemon, as always). Every device signs in once more. The rehearsed way uses a one-time join key, so nobody has to approve a login link. The key must belong to the device's own user (`headscale nodes list` shows it): with a key of another user, Headscale makes a second, new device instead of updating this one. ``` headscale preauthkeys create --user --expiration 1h # on the server tailscale debug prefs # on the device: note its current settings tailscale up --force-reauth --auth-key=file: --login-server= ``` `tailscale up` refuses, and changes nothing, if a setting the device already has (for example `--advertise-routes`, `--ssh`, `--hostname`) is missing from the command; it prints the full command to use. Repeat those settings; do not add `--reset`, which would drop them. A tagged device needs a tagged key (`--tags`); otherwise it loses its tags. Run it on each machine from its console or a local-network SSH session, never from a session that rides the tailnet. On a phone, sign out and back in (an interactive sign-in waits until you approve it on the server with `headscale auth register`; the rehearsal does not cover the phone app). Each device keeps its name, address and peers. Check on the server that none is left without a key: ``` sqlite3 /var/lib/headscale/db.sqlite \ "SELECT id, given_name FROM nodes WHERE deleted_at IS NULL AND (tka_key IS NULL OR tka_key = '');" ``` The answer must be empty. A device you no longer use can be deleted instead. ## 4. Start the lock on A (rehearsal: `disablement-secrets-prepared-before-init`, `init-with-two-signers-nobody-locked-out`) On A: ``` tailscale lock init --confirm --gen-disablements=0 disablement: disablement: tlpub: tlpub: ``` Only the prepared values go in; no new secret is printed. Every device that exists at this moment is signed by the start itself, so nobody is locked out. `tailscale lock` on any device shows the lock on, two trusted keys, and every device signed. ## 5. Add a new device (rehearsal: `new-device-filtered-then-admitted-by-signer-signature`) A new device joins as usual but is invisible to the others. On A or B: `tailscale lock sign nodekey: tlpub:` (both printed by `tailscale lock` on A or B under the unsigned devices). It then appears for everyone. ## 6. Escape (rehearsal: `non-owner-disable-refused`, `escape-with-prepared-secret-disables-lock`) From any device of the owner, in a shell with history off: `tailscale lock disable disablement-secret:`. The lock switches off for everyone, and stays off across restarts. Disablement is permanent for that Headscale database: the lock cannot be started again on it (see `integration/headscale/README.md`). A device of another user is refused (`403`) even with a valid secret. If the server is broken while the lock is on (tkad or Headscale will not run, so the lock cannot be switched off for everyone), run `tailscale lock local-disable` on each device, starting with the machines you need to reach. It stops only that device from enforcing the lock (rehearsal: `local-disable-affects-only-that-device`). Then repair or roll back the server. ## 7. Roll back to stock Headscale (rehearsal: `rollback-to-stock-headscale-on-current-database-reconnects-everyone`) Switch the lock off first (step 6), and check it: `tailscale lock status` on a device must say the lock is not enabled. The script cannot see whether the lock is on. If you roll back with the lock on, stock Headscale sends no signatures, every device that enforces the lock hides every other device, and only `tailscale lock local-disable` on each one brings them back. Then stop Headscale and tkad, copy the database (and its `-wal` and `-shm` files) aside, and run, with sqlite3 3.35 or newer: ``` sqlite3 -bail /var/lib/headscale/db.sqlite < integration/headscale/downgrade.sql ``` and start the stock binary. Every device reconnects. This works on SQLite only; there is no tested rollback for a PostgreSQL database. Stock Headscale refuses the database without this step. Do not restore the backup from step 1 instead: the devices signed in again in step 3, so the backup does not know their current keys. In one rehearsal run stock Headscale answered "node not found" to every device after that restore; the test does not check this, so treat it as observed once. To try omnet again later, do not start the patched server with the old tkad state directory: it still holds the disabled lock, and with the lock keys gone from the database it would stop service for every device until each signs in again. Start from step 1, start tkad with a fresh `tkad --init`, and do step 3 again (not rehearsed).