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 Rendered 1 # Runbook: turn on Tailnet Lock over a tailnet you already use 2 3 Every step below is rehearsed, in this order, by 4 5 ```sh 6 sh integration/e2e/run.sh --sudo-netns --scenario runbook --stock-headscale "$PWD/build/headscale-stock" 7 ``` 8 9 on a private tailnet in an empty network namespace, with the same shape as a small home tailnet: 10 two approving devices (**A** and **B**, `signer-a` and `signer-b` in the test), a server node, a 11 phone, and one device owned by another user. The test names its checks after the steps. Run it on the 12 exact build you will install, and stop if any check fails. 13 14 What the rehearsal does not cover: every device in it is the Linux command-line client v1.102.0. The 15 macOS app, the phone app, tagged devices and devices with extra settings (routes, exit node, Tailscale 16 SSH) are not in it; step 3 says what to check for them by hand. 17 18 Words used here: an **approving device** holds a lock key that may sign new devices. An **escape 19 secret** (Tailscale calls it a disablement secret) switches the lock off for the whole tailnet. 20 Its **value** is a one-way fingerprint of it that goes into the lock when it starts. 21 22 ## 0. Before the change window 23 24 1. Keep a way into the Headscale server **and into every machine you will sign in again in step 3** 25 that does not use the tailnet: its console, or SSH over the local network. Test each one now. An 26 SSH session that runs over the tailnet is not a way back in. 27 2. Make two escape secrets on an approving device and store each in a different safe place, never on 28 the Headscale server. Do this, and every later command that contains a secret or a join key, in a 29 shell whose history is off (`unset HISTFILE` in bash or zsh), and close that terminal afterwards; a 30 secret on a command line is also briefly visible in the process list. Secret: 31 `head -c 32 /dev/urandom | od -An -v -tx1 | tr -d ' \n'`. 32 Turn each into its value with `tailscale lock disablement-kdf ` and write the values down 33 (they are not secret). 34 3. On A and B run `tailscale lock` and note each `tlpub:` key. 35 4. Note the owner's numeric user ID (`headscale users list`) and every device (`headscale nodes list`), 36 including devices that are rarely online. 37 38 ## 1. Back up and install (rehearsal: `stock-tailnet-running-and-database-backed-up`) 39 40 1. Stop Headscale. Copy the database file and its `-wal` and `-shm` files, plus the config, to a dated 41 backup. Keep the stock `headscale` binary. 42 2. Install `tkad` and the patched `headscale`. 43 44 ## 2. Start omnet with the lock still off (rehearsal: `patched-headscale-adopts-existing-database-without-lock`) 45 46 Start tkad, then the patched Headscale with `OMNET_TKAD_SOCKET` and `OMNET_TKAD_ADMIN_USER_ID`. On this 47 first start run `tkad --init`: it creates the state directory and then keeps running as the 48 daemon. Leave out `--init` on every later start. 49 Every device reconnects and sees every other device. The lock is not on yet. 50 51 ## 3. Every device signs in once more (rehearsal: `init-refused-until-every-node-re-registers`, `every-node-re-registered-same-identity`) 52 53 Devices from before omnet have no lock key on record, so the owner's `tailscale lock init` is refused 54 with `409` (any other user's devices get `403` from the daemon, as always). 55 Every device signs in once more. The rehearsed way uses a one-time join key, so nobody has to approve 56 a login link. **The key must belong to the device's own user** (`headscale nodes list` shows it): 57 with a key of another user, Headscale makes a second, new device instead of updating this one. 58 59 ```sh 60 headscale preauthkeys create --user --expiration 1h # on the server 61 tailscale debug prefs # on the device: note its current settings 62 tailscale up --force-reauth --auth-key=file: --login-server= 63 ``` 64 65 `tailscale up` refuses, and changes nothing, if a setting the device already has (for example 66 `--advertise-routes`, `--ssh`, `--hostname`) is missing from the command; it prints the full command to 67 use. Repeat those settings; do not add `--reset`, which would drop them. A tagged device needs a tagged 68 key (`--tags`); otherwise it loses its tags. 69 70 Run it on each machine from its console or a local-network SSH session, never from a session that rides 71 the tailnet. On a phone, sign out and back in (an interactive sign-in waits until you approve it on the 72 server with `headscale auth register`; the rehearsal does not cover the phone app). Each device keeps its 73 name, address and peers. Check on the server that none is left without a key: 74 75 ```sh 76 sqlite3 /var/lib/headscale/db.sqlite \ 77 "SELECT id, given_name FROM nodes WHERE deleted_at IS NULL AND (tka_key IS NULL OR tka_key = '');" 78 ``` 79 80 The answer must be empty. A device you no longer use can be deleted instead. 81 82 ## 4. Start the lock on A (rehearsal: `disablement-secrets-prepared-before-init`, `init-with-two-signers-nobody-locked-out`) 83 84 On A: 85 86 ```sh 87 tailscale lock init --confirm --gen-disablements=0 disablement: disablement: tlpub: tlpub: 88 ``` 89 90 Only the prepared values go in; no new secret is printed. Every device that exists at this moment is 91 signed by the start itself, so nobody is locked out. `tailscale lock` on any device shows the lock on, 92 two trusted keys, and every device signed. 93 94 ## 5. Add a new device (rehearsal: `new-device-filtered-then-admitted-by-signer-signature`) 95 96 A new device joins as usual but is invisible to the others. On A or B: 97 `tailscale lock sign nodekey: tlpub:` (both printed by 98 `tailscale lock` on A or B under the unsigned devices). It then appears for everyone. 99 100 ## 6. Escape (rehearsal: `non-owner-disable-refused`, `escape-with-prepared-secret-disables-lock`) 101 102 From any device of the owner, in a shell with history off: `tailscale lock disable disablement-secret:`. The lock switches 103 off for everyone, and stays off across restarts. Disablement is permanent for that Headscale database: 104 the lock cannot be started again on it (see `integration/headscale/README.md`). A device of another 105 user is refused (`403`) even with a valid secret. 106 107 **If the server is broken while the lock is on** (tkad or Headscale will not run, so the lock cannot be 108 switched off for everyone), run `tailscale lock local-disable` on each device, starting with the 109 machines you need to reach. It stops only that device from enforcing the lock (rehearsal: 110 `local-disable-affects-only-that-device`). Then repair or roll back the server. 111 112 ## 7. Roll back to stock Headscale (rehearsal: `rollback-to-stock-headscale-on-current-database-reconnects-everyone`) 113 114 **Switch the lock off first (step 6), and check it:** `tailscale lock status` on a device must say 115 the lock is not enabled. The script cannot see whether the lock is on. If you roll back 116 with the lock on, stock Headscale sends no signatures, every device that enforces the lock hides every 117 other device, and only `tailscale lock local-disable` on each one brings them back. 118 119 Then stop Headscale and tkad, copy the database (and its `-wal` and `-shm` files) aside, and run, with 120 sqlite3 3.35 or newer: 121 122 ```sh 123 sqlite3 -bail /var/lib/headscale/db.sqlite < integration/headscale/downgrade.sql 124 ``` 125 126 and start the stock binary. Every device reconnects. This works on SQLite only; there is no tested 127 rollback for a PostgreSQL database. Stock Headscale refuses the database without this step. Do not 128 restore the backup from step 1 instead: the devices signed in again in step 3, so the backup does not 129 know their current keys. In one rehearsal run stock Headscale answered "node not found" to every 130 device after that restore; the test does not check this, so treat it as observed once. 131 132 **To try omnet again later**, do not start the patched server with the old tkad state directory: it 133 still holds the disabled lock, and with the lock keys gone from the database it would stop service for 134 every device until each signs in again. Start from step 1, start tkad with a fresh `tkad --init`, and do 135 step 3 again (not rehearsed).