The guide: Administering a Reach server
Reach is in development. Its packages are not published.
For the person who runs the Reach server after it is installed (Install the server). Everything here describes the current evaluation build, and where something is not built yet it says so. "From the code" means the statement comes from reading the source and its automated tests, not from a run on a Rocky machine.
Users and signing in#
The full guide is Users and sign-in. In short:
- Two steps for everyone. A password, then a six-digit code from an authenticator app. A person with no second step sets it up at their first sign-in, before they can see any page, and is given ten single-use recovery codes, shown once.
- The first owner is made by the setup link
initprints. After that owners and admins invite people from the Users page (a link, shown once), issue password-reset links, change roles (owners only) and disable people. Changes ask for the password and a fresh code again if the last confirmation was more than 10 minutes ago. - Sessions end after 60 minutes without activity and in any case after 12 hours. Between the password and the code a session lasts 5 minutes.
- Lockout. 5 wrong passwords in 15 minutes (same account or same address) refuse further sign-ins for the rest of the 15 minutes (kept in memory; a restart clears it). 10 wrong codes since that person's last good sign-in (forgotten only after a whole day with none; not "in an hour") pause their second step for an hour, doubling each time up to 7 days; owners see it on the Overview.
reach-server user reset <email> --unlocklifts a pause and resets the doubling. - Lost password or lost phone:
reach-server user reset <email> --password(a one-time link) or--totp(set the authenticator up again). Run on the server. This is also the way back in if the only owner loses everything. - Audit log: every sign-in, failure, pause, set-up, reset and user change is a row in a hash-chained log.
reach-server audit verifychecks it.
Backing up, and why the database and the KEK go together and apart#
What a working server consists of:
| What | Where (RPM install) | Why it matters |
|---|---|---|
| Database | SQLite file /var/lib/reach-server/reach.db (or your PostgreSQL database) | Machines, tools, findings, history, users, tokens |
| KEK, the key-encryption key | /var/lib/reach-server/kek | Opens the secrets stored in the database (the instance key, the salts of each tenant, meaning each organisation on the server, and token secrets). Without it the database cannot be used, and every Reach agent (the read-only program on each machine) must enrol again |
| Certificates | /var/lib/reach-server/tls/ (including ca.key, the evaluation CA's private key) | Agents' tokens pin the server certificate's key; losing it means new tokens and re-enrolling |
| Configuration | /etc/reach-server/server.toml | Where everything is, listen address, public URL |
Together: a backup you can restore needs the database and the KEK. A database backup without the KEK is unusable; a KEK without the database is worthless.
Apart: do not store them in the same place. A stolen database backup that comes with its KEK gives the thief the secrets; kept apart, it gives them nothing readable. Keep the KEK in a password manager or vault and the database backups on your normal backup storage, and write down where each lives.
Taking a backup in this build is manual (a backup command is planned; the steps below follow the code and have not been run):
- SQLite:
sudo systemctl stop reach-server, copy/var/lib/reach-server/reach.db(and anyreach.db-walandreach.db-shmbeside it) to a folder only root can read, for examplesudo install -d -m 0700 /root/reach-backupsthensudo sh -c 'cp -p /var/lib/reach-server/reach.db* /root/reach-backups/'(insidesh -c, so that root expands the*: your own shell cannot list a folder onlyreach-servercan read), thensudo systemctl start reach-server. PostgreSQL, with the database on this machine as the install guide sets it up (rolereach-server, databasereach, reached through the local socket): runpg_dumpas the service account, which owns the database.pg_dumpwrites to its standard output, which your shell opens as root throughsudo sh -c, so the service account needs no write access anywhere:
sudo install -d -m 0700 /root/reach-backups sudo sh -c 'umask 077; sudo -u reach-server pg_dump --format=custom --dbname=reach --host=/var/run/postgresql > /root/reach-backups/reach-$(date +%Y%m%d).dump'
For a database on another machine, run pg_dump with the address from your pg-url file instead of --dbname=reach --host=....
- Copy the KEK,
/var/lib/reach-server/tls/andserver.tomlonce, when you set up, and again aftertls renew. reach-server migratealready copies a SQLite database into abackupsfolder before it changes anything (see Upgrade and migrate).
Restore is the reverse. Install the same or a newer version of the package, stop the service (sudo systemctl stop reach-server), and put the files back with the owners and modes of the install guide: the key-encryption key at the path server.toml names (on the packaged install /var/lib/reach-server/kek) and reach.db, both owned by reach-server, mode 0600; /var/lib/reach-server/tls/ owned by reach-server, mode 0700, with ca.key and the server's key 0600; server.toml in /etc/reach-server/, root:reach-server, mode 0640. For PostgreSQL, restore into an empty database owned by the same role:
sudo -u postgres psql -c 'DROP DATABASE IF EXISTS reach' -c 'CREATE DATABASE reach OWNER "reach-server"'
sudo sh -c 'sudo -u reach-server pg_restore --dbname=reach --host=/var/run/postgresql --no-owner --exit-on-error < /root/reach-backups/reach-<date>.dump'DROP DATABASE deletes the current database: run it only when you mean to replace it with the backup. If the backup comes from an older version, run sudo -u reach-server /usr/bin/reach-server migrate (PostgreSQL: with --backup-done; the dump is your backup). Then sudo systemctl start reach-server, sign in, and run sudo -u reach-server /usr/bin/reach-server audit verify. None of these restore steps has been run yet; test a restore on a spare machine before you need one.
Replacing the certificate#
init --tls self-signed makes an evaluation CA and a server certificate valid for 397 days. Renew that one with sudo -u reach-server /usr/bin/reach-server tls renew (keeps the key, so agents keep working), or use your own certificate. A reverse proxy in front of the server is not available in this build: reach-server run refuses tls.mode = "proxy". Both ways that work, with exact commands, are in Certificates and TLS. The server logs tls.renew_needed when the certificate is close to expiry.
Firewall and ports#
- No proxy or port forwarder on the same host as the server. The server treats a connection from
127.0.0.1as the machine itself, and lets an account with no two-step sign-in set up from there only. Anything on the same host that relays other people's connections to the server would make them all look local. - By default the server listens only on the machine itself,
127.0.0.1:8443. Then no inbound firewall port needs opening, and agents on other machines cannot reach it yet. You reach the console through an SSH tunnel. - Order matters. Change
public_urlandlistenonly after every person has finished their second step; if you changedpublic_urlfirst, a sign-in through the tunnel from anything that is not a browser (a script,curl) is refused ("the request did not come from this site"). The recovery path is in Listening beyond this machine: setpublic_urlback tohttps://localhost:8443andlistenback to127.0.0.1:8443, restart, finish every second step through the tunnel, then change both again. - To listen on another address (see Listening beyond this machine; every user must have set up two-step sign-in first), open the TCP port of that listener, from the networks that hold the agents and the people using the console. With
agent_listenset, open the agent port to the agents' networks and keep the console port closed or limited to administrators. On Rocky:sudo firewall-cmd --permanent --add-port=8443/tcp(with--add-rich-ruleor a zone to limit the source) andsudo firewall-cmd --reload. If you set a separateagent_listen, that port too. - Outbound: the server needs no internet access to run.
dnfneeds your package mirrors for installs and updates. An agent needs to reach the server's address and port over HTTPS, and nothing else. - PostgreSQL, if you use it, is a connection from the server to the database (5432 by default); keep that off the wider network.
Logs#
- The server writes one JSON line per event to its standard error, and
systemdkeeps it in the journal:sudo journalctl -u reach-server, with-fto follow and--since "1 hour ago"to narrow. Each line carries its level to the journal as well (ERROR, WARN, INFO, DEBUG become the journal's error, warning, info and debug), sosudo journalctl -u reach-server -p warningshows warnings and errors only; the agent's service does the same (-u reach-agent). The level is added only when the output really is the journal's stream; run by hand, or with the output redirected to a file, the lines are plain JSON. A browser that does not trust the server's certificate, or a port scanner, causes a failed TLS handshake on every visit: those are logged at INFO ashttp.tls_handshake_failed, not as warnings. - It keeps no log file of its own. How long lines are kept is the journal's setting (
/etc/systemd/journald.conf,SystemMaxUseandMaxRetentionSec), not Reach's. If you need a longer record, forward the journal to your log system. - Log lines never contain request bodies, cookies, tokens, secrets or headers (design rule, checked by tests). The level is
log.levelinserver.toml(infoby default). - The audit log of sign-ins and changes is in the database and verified by
reach-server audit verify; the server writes each organisation's head hash to this log asaudit.anchorat start and every 24 hours. Keep those lines in your log collector (see the audit log).
What "Revoke" does to an agent that is already enrolled#
Nothing. A token is only used to enrol an agent. Revoke on the Add machines page stops that token from being used for further enrolments (a revoked token is refused with "This enrolment token has been revoked"; from the code and its tests). An agent that has already enrolled has its own identity and keeps reporting; revoking the token it used does not disconnect, remove or pause it.
Retiring or disabling one enrolled machine from the console is planned and not built. To stop a machine reporting, remove or stop the Reach agent on that machine (see Look after agents); until then a machine you no longer want stays listed, going silent once it stops reporting.
Checking what is running#
sudo curl --cacert /var/lib/reach-server/tls/reach-ca.pem https://localhost:8443/version--cacert checks the server's certificate against the evaluation CA; do not use -k, which switches the check off. sudo is needed because the certificate folder is private to the service account.