Repository navigation
Hetzner Flatcar
This runbook is for whoever runs the hardened production profile in deploy/hetzner-flatcar, as nylzo.com does: one Hetzner Cloud server on Flatcar Container Linux, with short restart windows and no failover. It covers provisioning, updates, host settings and recovery. Operations has the server settings, monitoring and troubleshooting.
- Three OpenTofu stacks with encrypted state and plans:
imagebuilds a verified Flatcar snapshot,servercreates the server and its cloud firewall,dnsmanages a Cloudflare zone without proxying. - Flatcar Stable updates itself and reboots between 03:00 and 04:00 UTC, which ends every live message. A new OS version that fails Nylzo's health check reboots back to the previous one.
- Nylzo runs in Docker with user namespace remapping and SELinux enforcing, 1 GiB of memory,
GOMEMLIMIT=512MiBand no route out. Caddy runs on the host and serves the web client from its own binary. - The cloud firewall and an nftables policy on the host each admit only 80/tcp, 443/tcp and 443/udp, ICMP, and SSH from the administrator networks. Each IPv4 address or IPv6 /64 may hold 64 connections to the web ports, and outgoing traffic is capped at 40 Mbit/s.
- Caddy accepts only TLS 1.3 with X25519MLKEM768 (transport), gets Let's Encrypt
shortlivedcertificates over HTTP-01 and writes no access log. - SSH admits only user
corewith a hardware-backed key and a touch on every login. - With the
strictprofile, data, pepper, Caddy's keys and the journal live on an encrypted volume that opens only while your Tang servers answer. - The epoch seed lives in
/run/nylzo-epochon tmpfs, and host policy refuses swap. Nylzo starts only aftersystemd-timesyncdhas synchronised the clock (expiry shares); until then the host report showsservicesas false. - Hetzner backups are off, because a restored snapshot would bring back messages that were already read or deleted.
Hetzner and your administrator accounts stay trusted, and root on the host can serve altered browser code.
- Create a dedicated Hetzner Cloud project. A Read & Write API token controls the server, so pass it to one command at a time, as
HCLOUD_TOKENfrom a password manager or a private file named inHCLOUD_TOKEN_FILE. - Turn on the strongest 2FA at Hetzner, the DNS provider, the registrar and GitHub.
- Pick administrator networks: IPv4 /24 or narrower, IPv6 /64 or narrower.
- Create a hardware-backed SSH key. With a FIDO2 security key:
ssh-keygen -t ed25519-sk -O verify-required -O resident. On a Mac with Touch ID,sc_auth create-ctk-identity -l nylzo-admin -k p-256-ne -t biocreates a Secure Enclave key andssh-keygen -w /usr/lib/ssh-keychain.dylib -K -N ""writes its key files. Check forbioin the Prot column ofsc_auth list-ctk-identities; a key created with-t nonesigns without asking. - Install mise, check out a reviewed revision and verify your
nylzoCLI. - For the strict profile, run two to five Tang servers at other providers. Firewall them to the server, log every request and alert on requests outside the reboot window.
umask 077
mkdir -p .deploy
mise run deploy init "$HOME/.ssh/id_ed25519_sk.pub" .deploy/productioninit writes state-encryption.key and site.json. Back the directory up away from the server, because without the key the OpenTofu state cannot be read. Keep site.json, which names your administrator networks, out of the repository.
| Field | Value |
|---|---|
domain, dnsZone
|
Host name and its zone; when equal, the apex gets a www redirect |
location |
nbg1, fsn1 or hel1
|
serverType, architecture
|
cax types are arm64, the others amd64
|
operator, contact, hosting
|
Transparency page; operator and contact are required |
dailyCreates |
NYLZO_GLOBAL_DAILY_CREATES, at most 500 |
initialRelease |
Release a new server starts with; planning checks its signature, Caddy build and host bundle |
automaticUpdates |
true installs signed releases on its own |
profile, tang
|
"strict" requires tang: a threshold and two to five servers with url and thumbprint
|
publicAccess |
false lets only the administrator networks reach HTTPS |
heartbeatUrl |
Optional heartbeat |
Read a Tang thumbprint with jose jwk thp -a S256 -i <signing key>.jwk.
mise run deploy plan image .deploy/production/site.json
mise run deploy apply image .deploy/production/site.json
mise run deploy plan server .deploy/production/site.json
mise run deploy apply server .deploy/production/site.jsonRead each plan before applying it. apply takes only the saved plan, with unchanged inputs and under an hour old.
The server's Ignition downloads the host bundle of initialRelease and checks its SHA-256 before the first boot. OpenTofu ignores later changes to Ignition and the image, so a running server changes only through signed releases and the host steps below.
Before the first SSH login, compare the host key fingerprint on the Hetzner console with the one SSH offers. Before you accept real traffic:
- Check DNSSEC, the CAA records, certificate issuance, the
wwwredirect, IPv4 and IPv6, and that SSH and the backend refuse other sources. - Run
nylzo verify-client --server https://your-domainwith the installed release's CLI, and create, read and burn test messages. - Test the heartbeat alert.
To open the service, set publicAccess: true and apply the server stack. Then set PUBLIC_ACCESS=true in /etc/nylzo/host.env and run sudo systemctl restart nylzo-firewall. Both firewalls must agree, also on ADMINISTRATOR_NETWORKS.
Create the zone in Cloudflare. The stack imports it with the records it manages and stops when a managed kind of record exists twice. Give the API token Zone Read, DNS Edit and SSL and Certificates Edit for this zone only, and pass it as CLOUDFLARE_API_TOKEN or CLOUDFLARE_API_TOKEN_FILE. site.json needs cloudflareAccountId.
mise run deploy plan dns .deploy/production/site.json
mise run deploy apply dns .deploy/production/site.json
mise run deploy outputs dns .deploy/production/site.jsonThe stack manages unproxied A and AAAA records, DNSSEC, a www CNAME for an apex domain, a null MX, v=spf1 -all, a DMARC reject policy, CAA issue "letsencrypt.org; validationmethods=http-01" with issuewild ";", and Universal SSL turned off. Then:
- Delegate to the printed name servers and publish the printed DS record at the registrar.
- After Caddy's first certificate, set
acmeAccountUrito its ACME account URL and apply again:
sudo /opt/nylzo/bin/jq -r .location /var/lib/caddy/caddy/acme/acme-v02.api.letsencrypt.org-directory/users/*/*.json- Check that
dig CAA your-domain +dnssecshows exactly two CAA records. - At the registrar, turn on the transfer, update and delete locks and auto-renew.
In misaon/nylzo, infrastructure.yml plans and applies the stacks from main. A push that changes a stack, the toolchain or the deploy tool plans in the infrastructure-plan environment and applies plans with changes in infrastructure. A daily run only plans and fails on drift.
One-time setup:
- Create a private S3-compatible bucket that supports conditional writes, which the state lock needs, and an access key for it only.
- With
NYLZO_STATE_BUCKET,NYLZO_STATE_ENDPOINT,NYLZO_STATE_REGION,AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEYset, runmise run deploy migrate server .deploy/production/site.jsonand the same fordns. A new plan must show no changes. - Create the environments
infrastructure-planandinfrastructure, limited tomain. Store in both the secretsNYLZO_SITE_JSON(site.json),NYLZO_STATE_PASSPHRASE(state-encryption.key),NYLZO_STATE_ENDPOINT,NYLZO_STATE_ACCESS_KEYandNYLZO_STATE_SECRET_KEY, plusHCLOUD_TOKENandCLOUDFLARE_API_TOKEN: read-only ininfrastructure-plan, Read & Write ininfrastructure. - Set the repository variables
NYLZO_STATE_BUCKET,NYLZO_STATE_REGIONandNYLZO_INFRASTRUCTURE_ENABLED=true. - Run
gh workflow run infrastructure.yml -f stack=image, thenstack=serverandstack=dns.
With automaticUpdates: true, nylzo-update.timer looks for a release every ten minutes.
- A newer patch of the installed line installs directly. A new minor or major line installs only when its
vX.Y.0carries a signedplannedapproval (Releasing), and then the host takes that line's newest patch. Downgrades are refused. - The release must be immutable, signed by the release workflow for its tag and have GitHub provenance. The updater runs the image on empty data without network, then runs its
store-checkon the live data, mounted read-only. Any failure leaves the running release as it is. - It installs the release's Caddy and host bundle
nylzo-host_X.Y.Z.tar(every host script, unit and configuration file), restarts only what changed, and goes back to the previous bundle if host policy or Caddy fails. Last, it stops Nylzo and starts the new image. - If the new release fails its health check on the live data, the updater stops Nylzo, writes
/var/lib/nylzo-deploy/failed.jsonand installs nothing more until you recover. It never restores an old database.
sudo systemctl status nylzo caddy nylzo-firewall nylzo-update.timer update-engine
sudo journalctl -u nylzo-initialize -u nylzo-update -u nylzo-ready -u nylzo
sudo cat /var/lib/nylzo-deploy/current.json; readlink /opt/nylzo/host/currentThe first start of 0.14.0 erases every stored message, the 0.13 seed and any stored abuse reports, so every earlier link stops working, and CLIs before 0.14.0 get client_outdated. The updater installs it once v0.14.0 is approved as planned.
- Tell your users when open messages will be deleted and that they need CLI 0.14.0 or later.
- Make sure
/etc/nylzo/service.envcontainsNYLZO_EDGE_REPORTS=1, which servers provisioned before the admin area lack. AnyNYLZO_REPORT_KEYline there is ignored. - After the upgrade, look for
store-upgradedandepoch-seed-createdinsudo journalctl -u nylzo. - Set
initialReleaseto the new tag insite.jsonandNYLZO_SITE_JSON, and dropreportPublicKey.
File in /etc/nylzo
|
Holds |
|---|---|
host.env |
AUTOMATIC_UPDATES, PUBLIC_ACCESS, ADMINISTRATOR_NETWORKS, HARDWARE_KEYS_ONLY, ENCRYPTED_STORAGE_REQUIRED, WWW_REDIRECT
|
service.env |
Nylzo's environment (configuration) |
caddy.env |
Domain and contact for Caddy; activation copies the contact from service.env
|
heartbeat.url |
Heartbeat address |
tang.json |
Tang servers |
After changing host.env, heartbeat.url or the contact, re-apply the current host bundle. After any change to service.env, also restart Nylzo:
sudo /opt/nylzo/runtime/activate "$(readlink -e /opt/nylzo/host/current)"
sudo systemctl restart nylzoActivation refuses HARDWARE_KEYS_ONLY=true while core has no hardware-backed key, and ENCRYPTED_STORAGE_REQUIRED=true without tang.json.
Flatcar rebuilds ~core/.ssh/authorized_keys from ~core/.ssh/authorized_keys.d at every boot, so manage keys as core with update-ssh-keys: -a NAME FILE.pub adds a key set, -l lists them, -d NAME removes one. Keep a second hardware key enrolled, since the console has no login.
The flag is /var/lib/nylzo-directive/maintenance, and Caddy treats it as Self-hosting describes. For nylzo.com, publish a signed directive instead:
gh workflow run watch.yml -f directive=maintenance
gh workflow run watch.yml -f directive=normalThe host checks every minute and applies only a newer directive for its own domain, which overrides a flag set by hand. Other instances use sudo touch and sudo rm on the flag.
For nylzo.com, watch.yml checks about every 30 minutes that production serves the web client of its signed release. A confirmed difference, or two failed runs in a row, opens a production-incident issue. A confirmed difference also publishes a maintenance directive and, with NYLZO_KILL_SWITCH_ENABLED=true, cuts the server's cloud firewall to administrator SSH, which a compromised server cannot undo.
- Create the environment
production-watchwith a 27-minute wait timer, limited tomain, then set the variableNYLZO_WATCH_CHAIN=true. - For the kill switch, create the environment
kill-switchlimited tomain, without a required reviewer, which would hold later runs. Store the secretsHCLOUD_TOKEN(Read & Write) andNYLZO_ADMINISTRATOR_NETWORKS, and set the repository variablesNYLZO_FIREWALL_IDandNYLZO_KILL_SWITCH_ENABLED=true. - Turn on GitHub notifications for assigned issues.
prepare writes a new pepper, and nylzo.service passes pepper.previous to Nylzo while it exists:
sudo mv /var/lib/nylzo-secrets/pepper /var/lib/nylzo-secrets/pepper.previous
sudo /opt/nylzo/runtime/prepare
sudo systemctl restart nylzoAfter seven days, delete pepper.previous and restart Nylzo. Deleting pepper without keeping it as pepper.previous closes every stored message.
With tang set, nylzo-storage.service keeps /var/lib/nylzo, /var/lib/nylzo-secrets, /var/lib/caddy and /var/log/journal on a LUKS2 volume in /var/lib/nylzo-storage.luks, which Clevis binds to your Tang servers. When the volume does not open, Nylzo, Caddy and the updater stay stopped, and a host with the volume file never falls back to plain directories. The volume takes the root filesystem's free space minus 8 GiB.
It protects against a copied disk, a leaked snapshot or backup, and a snapshot booted elsewhere. It does not protect against a compromised running host, or a token holder who boots the server into rescue mode while Tang answers.
After the first boot, add an offline recovery passphrase. Find the loop device with losetup -j /var/lib/nylzo-storage.luks and the Clevis slot with sudo clevis luks list -d <device>, then run sudo clevis luks pass -d <device> -s <slot> | sudo cryptsetup luksAddKey --key-file - <device> and store the new passphrase offline.
This needs host bundle 0.14.0 or later, and df /var/lib must show the size of the three data directories plus 17 GiB free. Work outside the reboot window with the Hetzner console open.
- Write
/etc/systemd/system/nylzo-storage.service.d/50-migration.confwith the lines[Unit]andAssertPathExists=/nonexistent, so nothing that needs the volume starts. Runsudo systemctl daemon-reloadandsudo systemctl stop nylzo-update.timer nylzo-host-status.timer, and wait untilsystemctl show --property=ActiveState --value nylzo-update.serviceno longer printsactivating. Runsudo systemctl stop nylzo-storage.service nylzo.service caddy.serviceand check thatsystemctl is-active nylzo.service caddy.serviceprintsinactivetwice. - Move
/var/lib/nylzo,/var/lib/nylzo-secretsand/var/lib/caddyaside, for example to/var/lib/nylzo.plain, and create an empty mode-700 directory in each place. The volume step empties/var/log/journal, so copy it first if you need old entries. - Write
/etc/nylzo/tang.jsonwith mode 600, such as{"t":2,"pins":{"tang":[{"url":"http://tang-a.example.net","thp":"<thumbprint>"},{"url":"http://tang-b.example.org","thp":"<thumbprint>"}]}}, and make surehost.envhas exactly one lineENCRYPTED_STORAGE_REQUIRED=true. - Run
sudo /opt/nylzo/runtime/storage.findmnt /var/lib/nylzomust show/dev/mapper/nylzo-storage[/nylzo]. If the step fails, fix the cause and run it again. - Copy each directory back, such as
sudo cp -a /var/lib/nylzo.plain/. /var/lib/nylzo/, compare withsudo diff -r, and add the recovery passphrase. Delete the drop-in, runsudo systemctl daemon-reloadand reboot. Delete the plain copies oncesystemctl is-active nylzo-ready.service nylzo.service caddy.servicereports all three active.
To give up before the reboot, keep the drop-in. If step 4 opened the volume, run sudo journalctl --relinquish-var, unmount /var/log/journal, /var/lib/caddy, /var/lib/nylzo-secrets, /var/lib/nylzo and /var/lib/nylzo-storage in that order, and run sudo cryptsetup close nylzo-storage. Detach the loop device of /var/lib/nylzo-storage.luks (or .new) and delete the file. Delete tang.json, set ENCRYPTED_STORAGE_REQUIRED=false, rmdir the empty directories, move each plain directory back with mv -T, delete the drop-in and reboot.
Afterwards add "profile": "strict" and tang to site.json and NYLZO_SITE_JSON. Free blocks of the old disk may still hold earlier data.
- Failed update: read
sudo journalctl -u nylzo -u nylzo-update. If the release refused the data without changing it, runsudo cp /var/lib/nylzo-deploy/previous.json /var/lib/nylzo-deploy/current.json,sudo rm /var/lib/nylzo-deploy/failed.jsonandsudo systemctl start nylzo. If it already changed the data (store-upgraded,rows-sealed), older releases cannot open it; deletefailed.jsononce a fixed patch is out and the updater installs it. - Kill switch: after the investigation, run
gh workflow run infrastructure.yml -f stack=server -f restore=trueandgh workflow run watch.yml -f directive=normal, then close the issue. Server applies stop while the firewall holds only kill-switch rules. - Suspected copy of the disk or a snapshot: deactivate the ACME account, revoke the certificate, rotate the pepper and rotate the Tang keys.
Use Nylzo
Run an instance
Implement
Contribute
Maintain
Brand