pr1v8.ca

Hardening three non-exit Tor relays on one VPS: offline keys, file integrity and unattended alerts

· 45 min read · torself-hostinghardeningdebian

I run three Tor relays on one rented virtual server with 4 vCPUs, 8 GB of RAM and one public IPv4 address per relay. They are guard and middle relays, never exits. Relay Search measures about 30 MB/s of capacity between them, and they mostly run without me.

This guide covers how they are built and hardened. The identity keys live off the server, file changes are checked every day, memory is sized so the relays stay in the consensus, and alerts only arrive when a person is needed. It also covers the parts that failed first. It is for someone with a spare VPS who wants to give bandwidth to Tor without it turning into a second job.

Relays are public by design. Every relay’s address, flags and bandwidth are in the hourly consensus[1], and its family is in the descriptors published alongside it[2], so you can check what this post says against the real thing:

In the rest of the post they are relay1, relay2 and relay3 in that order. Relay2 is the interesting one: it became a busy directory cache, and most of what I learned came from it.

What you need[3]:

The order, each step useful on its own:

  1. The host
  2. One tor process per address
  3. The torrc
  4. A family, and proof that it is yours
  5. Memory decides how many relays fit
  6. Two systemd limits that hurt
  7. Restarts cost flags
  8. Keep the identity key off the server
  9. Being told, not watching
  10. File integrity without the noise
  11. The rest of the hardening
  12. Smaller things that went wrong
  13. What is still open

One server, three relays VPS: 4 vCPU, 8 GB RAM, Debian 13 relay1 tor@default IPv4 + IPv6, port 443 queues up to 3 GB relay2 tor@relay2 IPv4, port 443 queues up to 3 GB relay3 tor@relay3 IPv4, port 443 queues up to 1.5 GB control on unix sockets, metrics on 127.0.0.1 only timers: watcher, self-heal, daily AIDE and dpkg --verify at home: master identity keys mint a 6-month signing key push alerts over HTTPS only when the state changes

1. The host#

Install tor from the Tor Project’s own repository rather than Debian’s, so security releases arrive within days. The Tor Project documents the repository setup.

Then let the box patch itself[8]. unattended-upgrades only installs from origins you list, so add the Tor Project’s[9], and let it reboot when a kernel update needs one[10]:

// /etc/apt/apt.conf.d/52tor-relay
Unattended-Upgrade::Origins-Pattern { "origin=TorProject"; };
Unattended-Upgrade::Automatic-Reboot "true";

Each tor upgrade restarts every relay and each kernel upgrade reboots the server. Both cost one flag for four days (section 7). I keep it on anyway: an internet-facing relay running an unpatched tor or kernel is the worse problem.

Add the extra addresses to the network config as /32 addresses so they survive a reboot. Two things caught me here. My firewall only allows SSH from a known address, so testing a new address on port 22 made it look unrouted when it was fine; test on the port the relay will use. And my provider’s gateway took a few minutes to start answering for a freshly added address, so a test straight after ip addr add failed and the same test later passed.

2. One tor process per address#

Debian’s tor package runs several independent instances. The default one, tor@default, reads /etc/tor/torrc. Each extra instance gets its own config, system user, data directory and unit[6]:

sudo tor-instance-create relay2
sudo tor-instance-create relay3

For relay2 that makes /etc/tor/instances/relay2/torrc, the user _tor-relay2, the data directory /var/lib/tor-instances/relay2/ and the unit tor@relay2.

Separate processes, not one tor with several ORPorts, for three reasons. Each relay needs its own identity. Tor’s main loop is single-threaded[11], so one process per relay is how a relay host uses more than one core[12]. And restarting one relay leaves the others alone.

A generator in the package starts every instance at boot[13][14]. systemctl status shows them as enabled-runtime; that is normal, don’t run systemctl enable on them.

To check a config before restarting, run the same --verify-config command the unit runs. systemctl cat tor@relay2 shows it in ExecStartPre[15]. An instance’s torrc depends on a defaults file with @@NAME@@ placeholders that the unit fills in first[15], so running tor --verify-config on the instance torrc by hand fails with an error that looks like a broken config when it isn’t.

3. The torrc#

Relay2’s config, with documentation addresses and an example domain in place of mine:

Nickname        ExampleRelay2
ContactInfo     ciissversion:3 email:tor[at]example[dot]com url:example.com proof:dns-familyid-ed25519

ORPort              198.51.100.12:443
Address             198.51.100.12
OutboundBindAddress 198.51.100.12

SocksPort   0
ExitRelay   0
ExitPolicy  reject *:*

ControlSocket        /run/tor-instances/relay2/control GroupWritable RelaxDirModeCheck
CookieAuthentication 1
MetricsPort          127.0.0.1:9036
MetricsPortPolicy    accept 127.0.0.1

FamilyId  <family-id>
MyFamily  $<relay1-fingerprint>,$<relay3-fingerprint>

MaxMemInQueues          3 GB
RelayBandwidthRate      10 MBytes
RelayBandwidthBurst     12 MBytes
MaxAdvertisedBandwidth  10 MBytes

OfflineMasterKey    1
SigningKeyLifetime  6 months
Sandbox             1

Line by line, where it isn’t obvious:

The memory and bandwidth lines are section 5, and the key lines are section 8.

4. A family, and proof that it is yours#

All relays run by one operator must declare themselves a family, so clients never put two of them in the same circuit[22]. On a single server this is the most important setting in the file. Since tor 0.4.9 it is done with a family key[23]:

tor --keygen-family myfamily

That writes myfamily.secret_family_key and prints a FamilyId line[23]. Copy the key file into each relay’s keys/ directory, owned by that instance’s user with mode 600, and put the FamilyId line in every torrc[23]. When you add a relay later, copy the same file. A newly generated key is a different family[23].

I also keep MyFamily listing the other fingerprints, for clients that don’t understand family IDs yet. The tor 0.4.9 manual still says to set both[18], although the Tor Project’s relay guide now describes MyFamily as removed[22]. The descriptors carry both.

Adding relay3 meant changing MyFamily on two running relays. That can be set live over the control socket with SETCONF[24], so neither restarted; then the same line went into both torrc files so it survives the next restart. Relay Search should show every member under effective_family and nothing under alleged_family. A one-sided claim lands in alleged_family[25].

To prove the relays are yours (the Authenticated Relay Operator ID), the ContactInfo above ends in proof:dns-familyid-ed25519, and one DNS record covers the whole family[26]:

we-run-this-tor-ed25519-family-id.example.com.  IN TXT  "<family-id>"

The value must match FamilyId exactly, and the zone must be signed with DNSSEC[26]. The operator setup guide I followed only described the older per-relay RSA proofs[27]; the ContactInfo specification at ciissversion:3 defines the family-ID ones[26][28], and when the two disagree the specification wins.

5. Memory decides how many relays fit#

A month in, relay2 dropped out of the consensus for about five hours. systemctl showed it as active the whole time, and nothing restarted it, because nothing had crashed.

How a busy relay fell out of the consensus 1. The uplink fills no bandwidth cap; the link pinned at 496 of about 500 Mbit/s 2. Queues grow faster than they drain relay2 wrote 18 times what it read: directory answers 3. Tor's own memory limit is reached MaxMemInQueues 2 GB; its OOM handler frees 1.4 GB, 3/4 buffers 4. The single main thread saturates above 100% of one core, killing circuits instead of serving 5. New connections are not accepted 4,096 wait in the kernel; the authorities cannot reach it Out of the consensus for about five hours, while systemd said active

Each step in that chain was measured, not guessed. Step 3 is where the memory went. When tor’s own out-of-memory handler fired, it reported roughly 0.5 GB of queued cells and 1.5 GB of connection buffers every time. About three quarters of the memory was socket buffers for some 9,000 connections, not relayed data.

That explains why the first fix only half worked. I capped bandwidth (RelayBandwidthRate, MaxAdvertisedBandwidth)[19], which stopped the link from saturating and stopped the immediate outage. But relay2’s CPU didn’t move at all: 108% of a core before the cap and after. What fixed it for good was giving the queues room: MaxMemInQueues from 2 GB to 3 GB[18]. Twelve days later the out-of-memory handler had fired zero times, the accept queue sat at zero, and relay2 was still running at 106% of a core. A relay can sit above 100% of one core for weeks and be fine, as long as it isn’t also fighting its own memory limit.

relay1 and relay2 on one server, measured the same day CPU, % of one core relay1 28% relay2 106% Directory requests per second relay1 1 relay2 431 Circuits created per second relay1 7 relay2 228 Peak memory since the last restart, MB relay1 1,523 relay2 4,159 Bars are scaled per row. Load follows requests, not bytes.

Directory requests are small and the answers are big, so a directory cache writes far more than it reads and costs CPU per request, not per byte. Size a relay by its request load, not its bandwidth. My first cap was sized from megabits per core, and it was wrong.

How I size memory now:

Today the three relays sit at about 1.0 GB resident each, 3.1 GB of 7.76 GB is in use, and swap is empty.

6. Two systemd limits that hurt#

Both of these looked like sensible guard rails, and both made things worse.

CPUQuota throttles bursts. I capped each relay at CPUQuota=150%. One evening relay1 started logging “Your computer is too slow to handle this many circuit creation requests”[18], dropped a third of its legacy circuit handshakes (114,608 of 342,623) and fell out of the consensus. The server had cores to spare. CFS bandwidth control counts per 100 ms period[31][32], and tor’s worker threads[11] burst inside a single period. After raising the quota to 300%, relay1 used 6.5% of its allowance and was still throttled 17 times in 90 seconds. Any finite quota does this under load. CPUWeight is the safe alternative: it only matters when cores are contended, and it never throttles against idle ones[33].

MemoryHigh reclaims instead of protecting. MemoryHigh is a soft limit: above it the kernel reclaims the cgroup’s memory constantly[34]. Relay1 logged 878,673 such events while sitting just under its limit, spending CPU without ever being in danger. MemoryMax is a hard wall that does nothing until it is hit[31]. Use that, set well above the measured peak, so a runaway relay can’t take the whole server and nothing happens otherwise.

The drop-ins I use now, one pair per relay. systemctl edit --drop-in=zz-cpu tor@relay2 opens the first one in the right directory[35]:

# zz-cpu.conf
[Service]
CPUQuota=
CPUWeight=100
TasksMax=4096
# memory.conf
[Service]
MemoryHigh=infinity
MemoryMax=5G

The empty CPUQuota= clears any quota set by an earlier file[31]. Drop-ins apply in lexicographic order and the last one wins[36], hence the zz- prefix.

Cgroup limits don’t need a tor restart: systemctl set-property --runtime changes them on a live unit. The trap is the word runtime. It writes to /run, which is gone at the next reboot[35]. My original quota existed only there, so the next automatic reboot would have silently changed the limits. Put the values you want to keep in /etc, and check that nothing important lives only in /run:

systemctl show tor@relay2 -p DropInPaths

7. Restarts cost flags#

Flags decide how much traffic a relay gets[37], and most of them survive a short restart. Only one doesn’t:

Flag What the directory authorities look at After a one-minute restart
Running they reached it in the last 45 minutes[21] usually nothing
Guard fraction of each day it was up, plus how long it has been known[21] negligible
Stable a decaying average of how long each uptime lasted[21] a small dip
HSDir at least 96 hours of continuous uptime[21] gone for four days

Turning off automatic reboots to protect Guard looks sensible and isn’t: a one-minute reboot is 0.07% of a day. HSDir comes and goes with every tor or kernel update, roughly monthly, and that’s the price of patching.

Three habits keep restarts rare:

8. Keep the identity key off the server#

A relay’s permanent identity is an ed25519 master key[40]. Normally it sits in the data directory, so anyone who copies the disk can impersonate the relay forever. With OfflineMasterKey 1, tor never loads the master key[18]. It runs on a signing key the master key has certified for a limited time, here six months[40], and the master key lives somewhere else.

Moving an existing relay over, once:

  1. Copy the whole keys/ directory off the server and keep it somewhere safe. That copy is now the only thing that can renew the relay.
  2. On a trusted machine, mint a six-month signing key from that copy with the renewal command below, and put the two signing files in the relay’s keys/ directory.
  3. Add OfflineMasterKey 1 and SigningKeyLifetime 6 months to the torrc and restart the relay once.
  4. Delete ed25519_master_id_secret_key from the server and check the fingerprint didn’t change.

I did the one restart while HSDir was already missing after an unplanned reboot, so it cost nothing extra.

Renewal happens on a trusted machine at home, not on the server:

work=$(mktemp -d -p /dev/shm); mkdir -m 700 "$work/keys"
cp ed25519_master_id_secret_key ed25519_master_id_public_key "$work/keys/"
tor -f /dev/null --DataDirectory "$work" --SigningKeyLifetime "6 months" --keygen
# copy $work/keys/ed25519_signing_cert and ed25519_signing_secret_key to the relay's
# keys/ directory (owner = that instance's user, mode 600), then:
shred -u "$work"/keys/*; rm -rf "$work"

Two details in there are easy to get wrong:

My script for this pulls the key backup from my password manager into memory, checks that each master public key matches the one on the relay before minting anything, copies only the two signing files, and shreds the masters when it exits. It costs one unlock and one hardware-key touch.

Tor checks its keys on a timer[42] and should pick up a newer signing certificate from disk by itself, so renewal shouldn’t need a restart[43]. My first real renewal is months away, so I haven’t seen that happen yet. The script has passed a full dry run against all three relays.

The expiry date is inside the certificate file, after a 32-byte text header, as four big-endian bytes of hours since 1970[44][45]:

h=$(od -An -tu4 --endian=big -j34 -N4 /var/lib/tor/keys/ed25519_signing_cert | tr -d ' ')
date -u -d @$((h*3600))

My watcher alerts weeks before expiry and again close to it. If renewal is missed the relays stop working[40], but nobody can take over their identity.

What this doesn’t cover: the legacy RSA identity key and the family key stay on the server. The RSA key can’t be moved offline the same way[46]. The family key could be, but that is more work.

9. Being told, not watching#

A timer runs a check script every few minutes. It pushes a notification only when the overall state changes, to problem or back to healthy, so a long outage is one message, not a hundred. It sends over plain HTTPS[7] rather than through Tor, so alerts still arrive when Tor is the thing that’s broken. The state only advances after a confirmed send, so an outage at the push service delays an alert rather than losing it.

curl -fsS --data-urlencode "token=<app-token>" --data-urlencode "user=<user-key>" \
     --data-urlencode "title=relay problem" --data-urlencode "message=$msg" \
     --data-urlencode "priority=1" https://api.pushover.net/1/messages.json

What it checks, and why each one is there:

curl -s http://127.0.0.1:9036/metrics | grep '^tor_relay_flag' | grep ' 1$'

Every flag is listed with 0 or 1[47], so leave out the filter and you get nonsense. - Accepted connections: this is the check that would have caught the outage in section 5. ss -ltn shows how many connections wait in each ORPort’s accept queue in its Recv-Q column[48]; a number that stays high means tor is up but not accepting. - Lost flags: it remembers which flags each relay had and alerts when one goes. It stays quiet after a restart until HSDir has had time to come back by itself. - Counters as differences: tor’s overload counters (dropped handshakes, OOM bytes, TCP port exhaustion) only ever go up[47]. Compare each to its previous value. Alert on the absolute number and one bad evening keeps the alert on forever. - Exit tripwire: it reads ExitRelay from both the torrc and the running config over the control socket[24], because a relay’s running config can differ from its file. - Signing certificate expiry, from section 8.

Two more pieces: a boot service sends a quiet notification on every boot, so an unexpected reboot never goes unnoticed, and a separate follower copies tor’s notices to a rotated file. The journal here is kept in RAM only[49], and without the copy an overnight reboot would erase the evidence of whatever caused it. Tor’s SafeLogging is on by default, so client addresses never reach the log[19].

Outside the server, the Tor Project’s own relay alert service, Tor Weather, emails me if a relay goes offline[22]. That covers the one case a watcher on the server can’t report: the server itself being down.

10. File integrity without the noise#

I wanted to know if anyone changed files on the server, so I installed AIDE, a file-integrity checker: it records hashes and metadata in a database[50] and reports any difference each day. With Debian’s default rules[51] it tracked over 41,000 files, including every kernel module. The first few alerts were my own changes and cache files, which I pruned one by one. Then a kernel update arrived, the server rebooted into it, and for three nights I woke up to a priority alert listing five thousand added and five thousand removed files. All of it was the upgrade. An alert that fires after every upgrade gets ignored, and then a real one gets ignored too.

What checks what AIDE: hashes and metadata, daily /etc, relay identity and family keys own scripts, login files, SSH keys, dpkg checksum lists dpkg --verify, daily every file a package installed (/usr, /boot) against the checksums its package shipped Not watched, on purpose files that change on their own: runtime state, caches, logs, rotating keys AIDE database, entries before 41,145 after 3,034

So the work is split:

dpkg --verify | grep -v ' c /' # drop config files; those are AIDE's job

On my server that prints a single line, a directory the AppArmor package expects that doesn’t exist here, so the daily check carries an allowlist for it. - Files that change on their own, such as runtime state, caches, logs and tor’s statistics, are left out of AIDE with prune rules (lines starting with ![53]) in a file under /etc/aide/aide.conf.d/.

The database went from 41,145 entries to about 3,000. Getting there taught me four things about AIDE that the defaults don’t make obvious:

To prove the scope, I created a file in each kind of place and ran a check. New files in /usr/local/sbin and /etc/tor were reported, new files in /usr/bin and /boot were not. Then I learned that creating and deleting a file changes the parent directory’s timestamps[57], so the next morning’s check reported my own test. Re-baseline after a test like that.

A root attacker on a running server can rewrite the AIDE database[50], so this mainly catches changes made while the server was off, or by something without root. I keep the database immutable (chattr +i[58]) and store its hash off the server; after every deliberate re-baseline the stored hash gets updated.

11. The rest of the hardening#

Briefly, because none of this is unusual:

12. Smaller things that went wrong#

13. What is still open#

Updated: 2026-10-14

Sources#


  1. Glossary: consensus, Tor Project. The directory authorities vote on the consensus once per hour. ↩︎↩︎

  2. Computing microdescriptors, Tor directory protocol spec. Family membership travels in descriptors (family, and family-ids in newer consensus methods), not in the consensus. ↩︎

  3. Relay requirements, Tor Project. Minimum bandwidth, RAM, IPv4 and uptime for a relay. ↩︎

  4. Technical considerations, Tor Project. Follow the VPS provider’s terms of service; many providers do not allow exit relays. ↩︎

  5. Good Bad ISPs, Tor Project. Check a host’s TOS and AUP before running a relay; non-exit relays do not attract complaints. ↩︎

  6. tor-instance-create(8), Debian. Creates an instance’s _tor- user, data directory and torrc; the main instance is tor@default with /etc/tor/torrc. ↩︎↩︎

  7. Pushover Message API, Pushover. The HTTPS-only messages endpoint, the token, user, title and message parameters, and priority 1 as high priority. ↩︎↩︎

  8. Debian/Ubuntu relay setup, Tor Project. Puts automatic security updates first among the setup steps. ↩︎

  9. Debian and Ubuntu: automatic updates, Tor Project. The unattended-upgrades configuration with the origin=TorProject pattern and the optional Automatic-Reboot line. ↩︎

  10. unattended-upgrades README, unattended-upgrades project. Origins-Pattern decides which origins are upgraded; Automatic-Reboot reboots when /var/run/reboot-required exists. ↩︎

  11. Threading in Tor, Tor source documentation. One main thread handles networking; worker threads take CPU-heavy work. ↩︎↩︎

  12. Multithreaded crypto/networking (#23), Tor Project GitLab, scalability and performance board. Without multithreaded crypto or networking, fast links need several tor instances. ↩︎

  13. tor-generator in Debian’s tor package, Debian. Adds every instance under /etc/tor/instances to tor.service at boot. ↩︎

  14. systemd.generator(7), systemd. Generators run early at boot and create units, drop-ins and symlinks. ↩︎

  15. tor@.service in Debian’s tor package, Debian. Fills @@NAME@@ into the defaults file, runs --verify-config in ExecStartPre, and sets ReadOnlyDirectories=/. ↩︎↩︎↩︎

  16. tor(1): client options, Tor Project, Debian copy. SocksPort defaults to 9050; FascistFirewall assumes a firewall that allows ports 80 and 443. ↩︎↩︎

  17. tor(1): directory server options, Tor Project, Debian copy. DirCache defaults to 1 and clients use the ORPort; relays no longer publish a DirPort. ↩︎↩︎

  18. tor(1): server options, Tor Project, Debian copy. Address, ExitRelay, MaxMemInQueues and its circuit killing, MaxOnionQueueDelay, MyFamily and FamilyId (set both for older clients), OfflineMasterKey. ↩︎↩︎↩︎↩︎↩︎↩︎↩︎

  19. tor(1): general options, Tor Project, Debian copy. OutboundBindAddress, ControlSocket and GroupWritable, the warning against exposing MetricsPort, RelayBandwidthRate, MaxAdvertisedBandwidth, SafeLogging (default 1) and the seccomp Sandbox. ↩︎↩︎↩︎↩︎↩︎↩︎

  20. Types of relays on the Tor network, Tor Project. Guard and middle relays rarely get abuse complaints; complaints about an exit go to its operator. ↩︎

  21. Assigning flags in a vote, Tor directory specification. The Running, Stable, Guard, V2Dir and HSDir rules; a DirCache 0 relay loses V2Dir and so cannot be a Guard. ↩︎↩︎↩︎↩︎↩︎↩︎

  22. Relay post-install and good practices, Tor Project. An operator of several relays must declare a family so clients do not use them in one circuit; Tor Weather sends offline alerts; it also says MyFamily, the previous family method, has been removed. ↩︎↩︎↩︎

  23. Learn how to configure your relays’ FamilyId, Tor Project. Needs tor 0.4.9.2-alpha or later; covers the key, the FamilyId line and changing keys. ↩︎↩︎↩︎↩︎

  24. Control protocol commands, Tor control specification. SETCONF changes options in the running tor; GETCONF reads them. ↩︎↩︎↩︎

  25. Onionoo protocol, Tor Metrics. The data source for relay status sites; defines effective_family (mutual) and alleged_family (one-sided). ↩︎↩︎

  26. ContactInfo Information Sharing Specification: proof, nusenu. Version 3 proofs use the family ID; the DNS method needs DNSSEC and one TXT record at we-run-this-tor-ed25519-family-id. plus the domain, holding the 43-character, case-sensitive family ID. ↩︎↩︎↩︎

  27. Proposal 326: the “tor-relay” well-known resource identifier, Tor specifications. The per-relay rsa-fingerprint.txt proof file, alongside the later family ID file. ↩︎

  28. CIISS version 3: easier proof based on Happy Family ID, Tor Forum, tor-relays list. The specification’s author announcing family-ID proofs in place of per-relay fingerprint proofs. ↩︎

  29. swappiness, Linux kernel documentation. How the kernel weighs swapping against dropping page cache. ↩︎

  30. crypttab(5), systemd, man7.org copy. /dev/urandom as the key file gives swap a random key; without nofail a device is a hard dependency of the boot. ↩︎↩︎

  31. systemd.resource-control(5), systemd. CPUQuota and its 100 ms default period, an empty CPUQuota= unsets the quota, MemoryHigh throttles, MemoryMax is the absolute limit. ↩︎↩︎↩︎

  32. CFS Bandwidth Control, Linux kernel documentation. A group that uses up its quota is throttled until the next period. ↩︎

  33. Control Group v2: weights, Linux kernel documentation. Weights only divide CPU among children that are using it. ↩︎

  34. Control Group v2: memory interface files, Linux kernel documentation. Above memory.high the cgroup is throttled and reclaimed; the high count in memory.events records it. ↩︎

  35. systemctl(1), systemd. edit --drop-in=, and set-property --runtime changes that last until the next reboot. ↩︎↩︎

  36. systemd.unit(5), systemd. Drop-in files are applied in lexicographic order. ↩︎

  37. The lifecycle of a new relay, Tor Blog. How gaining flags changes the traffic a relay gets. ↩︎

  38. Nyx, Tor Project. A terminal relay monitor whose configuration editor changes settings on the fly. ↩︎

  39. Stem, Tor Project. A Python library for the tor control protocol. ↩︎

  40. Offline ed25519 identity keys, Tor Project. The master identity key, the medium-term signing key and its certificate, and tor exiting when they expire. ↩︎↩︎↩︎

  41. tor(1): command-line options, Tor Project, Debian copy. --keygen, --keygen-family, and -f defaulting to /etc/tor/torrc. ↩︎↩︎

  42. relay_periodic.c: check_ed_keys_callback, Tor source documentation. Every 30 seconds a relay checks whether it is time to load new ed25519 signing keys. ↩︎

  43. Offline Relay Identity Keys, Tor Project legacy Trac wiki, archived. Renewal with tor --keygen; no restart or reload is needed after copying in the renewed keys. ↩︎

  44. Binary certificate formats, Tor specifications. The expiration field is four bytes of hours since the epoch, after the version and type bytes. ↩︎

  45. Integer encoding, Tor specifications. Multi-byte integers are big-endian. ↩︎

  46. tor(1): files, Tor Project, Debian copy. The ed25519 master secret key can be kept offline, the RSA secret_id_key signs router descriptors, and onion keys keep a .old copy. ↩︎↩︎

  47. Overloaded relays and bridges, Tor Project. The MetricsPort tor_relay_flag gauge and overload counters, the 72-hour overload marker, and sysctl tuning. ↩︎↩︎↩︎↩︎↩︎

  48. SYN packet handling in the wild, Cloudflare blog. For a listening socket, ss shows the accept queue’s length as Recv-Q and its limit as Send-Q; ss(8) itself does not document this. ↩︎

  49. journald.conf(5), systemd. Storage=volatile keeps the journal in memory only. ↩︎

  50. AIDE manual, AIDE project. The database of attributes and hashes, how rules are matched, and that the database itself can be altered. ↩︎↩︎↩︎

  51. aide-common file list, Debian. The numbered default rule files in aide.conf.d and the daily check timer. ↩︎

  52. dpkg(1): --verify, dpkg. Compares installed files with the md5sums stored in the dpkg database; c marks a conffile. ↩︎↩︎

  53. aide.conf(5): rules, AIDE. ! rules, the implicit ^ before each expression, and deepest-node then first-match. ↩︎↩︎↩︎

  54. aide.conf(5): macro lines, AIDE. Files from an included directory are read in lexical order. ↩︎

  55. Tor network parameters: onion-key-rotation-days, Tor specifications. Default 28 days, with the previous key still accepted for a grace period. ↩︎

  56. dpkg(1): filesystem filenames, dpkg. The .dpkg-new and .dpkg-tmp files written beside each path during unpack. ↩︎

  57. inode(7), Linux man-pages. A directory’s mtime changes when a file in it is created or deleted. ↩︎↩︎

  58. chattr(1), e2fsprogs. A file with the i attribute cannot be modified. ↩︎

  59. Simple ruleset for a server, nftables wiki. An input chain with policy drop. ↩︎

  60. IP Sysctl, Linux kernel documentation. tcp_syncookies, tcp_congestion_control and ip_local_port_range, among others. ↩︎↩︎

  61. tor(1): denial of service mitigation options, Tor Project, Debian copy. Relays take these values from consensus parameters unless set by hand. ↩︎

  62. tor package file list, Debian. Includes /etc/apparmor.d/system_tor. ↩︎

  63. systemd.exec(5), systemd. AppArmorProfile=, ReadOnlyPaths= and ProtectKernelTunables=. ↩︎↩︎

  64. systemd NEWS, systemd. Version 231 renamed ReadOnlyDirectories= to ReadOnlyPaths= and kept the old name working. ↩︎

  65. proc_pid_attr(5), Linux man-pages. /proc/pid/attr is the security-module interface: current holds the process’s attributes and exec sets them for the next execve. ↩︎↩︎

  66. modules_disabled, Linux kernel documentation. Once set, modules cannot be loaded or unloaded and the switch cannot be turned back off. ↩︎

  67. Recommended Settings, Kernel Self Protection Project. The usual boot options, turning module loading off after boot, and disabling user namespaces. ↩︎↩︎

  68. The kernel’s command-line parameters, Linux kernel documentation. init_on_alloc, init_on_free, randomize_kstack_offset, slab_nomerge, vsyscall and lockdown. ↩︎

  69. INIT_ON_FREE_DEFAULT_ON in security/Kconfig.hardening, Linux kernel source, tag v6.12. Most workloads see a 3 to 5% slowdown. ↩︎

  70. Client Authorization, Tor Project. Only clients that hold a key can reach the onion service. ↩︎

  71. capabilities(7): CAP_DAC_OVERRIDE, Linux man-pages. Bypasses file read, write and execute permission checks. ↩︎

  72. pkill(1): -f, procps. With -f the pattern is matched against the full command line. ↩︎