# secrets Encrypted with [agenix](https://github.com/ryantm/agenix). Nothing here is required: a secret is only used when its `.age` file exists. | File | Purpose | | ----------------------- | -------------------------------------------------------------- | | `faumaray-password.age` | Hashed login password (`mkpasswd -m yescrypt`) | | `ssh-id_ed25519.age` | Private SSH key for the user | | `ssh-id_ed25519.pub` | Matching public key, plaintext (optional) | 1. Replace the placeholder public keys in `secrets.nix` (host key and your own). 2. `cd secrets && agenix -e faumaray-password.age` 3. `git add` the new `.age` files: flakes only see tracked files. Decryption on the machine uses `/etc/ssh/ssh_host_ed25519_key`. ## Service secrets Three more optional secrets belong to services. Without them the service is switched off, and the build prints a warning that names the missing file. | File | Content | Used by | Without the file | | ------------------------ | ------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- | | `gitea-runner-token.age` | One line `TOKEN=` | `modules/dev/gitea-runner.nix` (`tokenFile`) | The runner "performance" is not configured | | `tg-ws-proxy-secret.age` | The hex secret (32 hex digits) | `modules/network/proxy-suite.nix` (`secretFile`) | `services.proxy-suite.tgWsProxy` stays off | | `amneziawg-ai.age` | The whole AmneziaWG client .conf (AWG 1.x to 3.x) | `modules/network/proxy-suite.nix` (`amneziaWg.profiles.ai.configFile` and `profiles.vpn.configFile`) | No AmneziaWG tunnel, no TProxy, no perAppRouting: the proxy stays off | All three are decrypted to `/run/agenix/` (root, mode `0400`) and read by the service units. No `.nix` file contains a secret value. Create them from the repository root (`-i` checks that your key can decrypt the result; `secret-from-file` also runs `git add` on the new file). The first two values go through a pipe, so they never touch the disk or a command line: ```sh # Registration token: Gitea -> Site Administration -> Actions -> Runners. printf 'Registration token: '; read -rs t; echo printf 'TOKEN=%s\n' "$t" | nix run .#secret-from-file -- gitea-runner-token.age - -i ~/.ssh/id_ed25519 unset t # Telegram proxy secret: a fresh random value. s=$(od -An -N16 -tx1 /dev/urandom | tr -d ' \n') && [ "${#s}" -eq 32 ] && echo "$s" >&2 \ && printf '%s\n' "$s" | nix run .#secret-from-file -- tg-ws-proxy-secret.age - -i ~/.ssh/id_ed25519 unset s ``` The second command also prints the secret once, because the Telegram clients need it. The AmneziaWG config is a whole file, the client `.conf` that AmneziaVPN exports (it holds the private key, so treat it as one). Keep it outside the repository, encrypt it, and delete the plaintext: ```sh nix run .#secret-from-file -- amneziawg-ai.age /path/to/client.conf -i ~/.ssh/id_ed25519 rm /path/to/client.conf ``` The plaintext must not stay in the repository (a `/WG.conf` in the repository root is gitignored, but delete it all the same). `secret-from-file` already ran `git add` on `secrets/amneziawg-ai.age`, so there is nothing left to stage. The same file also backs the full-tunnel profile `vpn` (all traffic, not autostarted): `proxy-ctl awg on vpn` brings it up and `proxy-ctl awg off` takes it down. Starting it stops the global TProxy, zapret and the `ai` split tunnel (same peer); stopping it starts TProxy (with `ai`) and zapret again by itself, and so does a switch, which ends the full tunnel (see the header of `modules/network/proxy-suite.nix`). A second peer for `vpn` (another secret and a `profiles.vpn.configFile` that points at it) would only keep `ai` up beside the full tunnel, and only once the unconditional conflicts and after of `proxy-suite-awg-vpn` on `awg-ai` in that file are dropped: TProxy and zapret stop either way. Then switch (`nix run .#switch`). ### Rotation Earlier versions of this repository (up to commit `030e97e`) kept the runner token and the Telegram proxy secret as plaintext in the networking configuration; both are still in the git history. Treat them as leaked: create a new registration token in Gitea (and remove the old runner there), generate a new Telegram secret, and store the new values with the commands above. To replace an existing file later, add `--force`: ```sh s=$(od -An -N16 -tx1 /dev/urandom | tr -d ' \n') && [ "${#s}" -eq 32 ] \ && printf '%s\n' "$s" | nix run .#secret-from-file -- tg-ws-proxy-secret.age - --force -i ~/.ssh/id_ed25519 unset s ```