TachEmail r90
Docs / Install / Configure and install

Configure and install

Fill in the config, run the installer, and check that Tach and HTTPS report the installed revision.

Built from commit f569b4a on Nov 14, 2026

This page is generated from the maintained install guide, GUIDE.md, at source commit fa247a8. Keep the signed guide that came with your installed release.

Configure

Run these commands inside tach-package-VERSION. Copy the example config to a private file, edit it, and check it with validate. Repeat the edit and validate until it prints Configuration valid:

sudo install -m 600 -o root -g root config.example.toml /root/tach-config.toml
sudoedit /root/tach-config.toml
sudo python3 -I ./tach.py validate --config /root/tach-config.toml

Set every value:

  • domain: the hostname from your DNS record.
  • admin_email: the first administrator’s email address.
  • timezone: the IANA timezone that defines your accounting days, such as America/Chicago.
  • data_dir: where the database lives. Tach keeps its verified backups in the backups directory inside it.
  • [smtp]: your relay’s host, port, tls (tls or starttls) and the from sender.
  • [backup]: retention, the number of verified backups to keep (1 to 90), and max_mib, the largest database a backup accepts, in MiB. The example’s 256 is a starting value: raise it as the database grows. See Back up.
  • [public_ingest]: optional; see Ingest-only hostname.

validate refuses the example’s example.com domain, administrator email, SMTP host and sender, and names each field that still has one. The data_dir path must be absolute and must not contain whitespace, commas, colons or symlinks. The config file must be root-owned with mode 0600 (0400 is also accepted). Leave [entra] enabled = false: Entra sign-in is not available yet. A config from an earlier package that still sets backup.directory is refused: delete that line.

Relay credentials

Relay authentication is optional. To use it, put the username and the password each in its own private, root-owned, mode 0600 file holding one line. Set username_file and password_file to their absolute paths. Otherwise leave both empty. Leave username_env and password_env unset: Ubuntu’s default sudo drops environment variables, and files keep repeat installs independent of the shell. Never put a secret in the config, shell history, evidence or logs.

Mail routes: ACS, Exchange Online, or internal relay

  • Azure Communication Services SMTP: keep username/password mode above, using the ACS SMTP credentials, approved sender, TLS and port supplied by IT.
  • Exchange Online (commercial Microsoft 365): set host smtp.office365.com, port 587, TLS starttls. Remove username/password sources. Set smtp.oauth_tenant_id and smtp.oauth_client_id to the app’s UUIDs, smtp.oauth_mailbox to the authorized sending mailbox and smtp.oauth_client_secret_file to an absolute root-owned mode 0600/0400 single-line secret file. This is SMTP app authentication, not Entra user sign-in; keep entra.enabled = false. Certificate credentials and sovereign Microsoft clouds are not supported by this configuration.
  • Internal relay: retain its approved username/password pair or leave both empty for an IP-authorized relay. Use verified STARTTLS/TLS. For a private CA, set smtp.ca_bundle_file to an absolute root-owned mode 0600/0400 PEM CA bundle (one or more certificates). Public trust remains enabled, as do hostname and chain verification. No verification bypass exists. The installer snapshots trust bytes into root-private runtime.env as TACH_SMTP_CA_BASE64; no secret source or trust file needs a writable container mount. Re-run the installer after rotating the client secret or CA bundle.

For Exchange, IT must grant the Office 365 Exchange Online application permission SMTP.SendAsApp and admin consent, register the service principal in Exchange with New-ServicePrincipal using the Enterprise Application object ID (not the app registration object ID), authorize the mailbox, and grant SendAs when needed. SMTP AUTH must be permitted by the organization’s mailbox/security policy. Follow Microsoft’s current SMTP OAuth guide and client credentials protocol (verified 5 November 2026); do not substitute delegated SMTP.Send or Graph scopes.

Tach posts a URL-encoded client-credentials request to https://login.microsoftonline.com/{tenant-id}/oauth2/v2.0/token with scope https://outlook.office365.com/.default, then authenticates SMTP with SASL XOAUTH2. Tokens live only in memory, shared across concurrent sign-ins, and are reacquired 60 seconds before expiry (shorter-lived tokens are not cached). A failed SMTP attempt evicts its token; a later sign-in can recover. There is no automatic resend or password fallback.

tach validate refuses incomplete fields with SMTP OAuth requires tenant ID, client ID, mailbox and client secret file, mixed modes with SMTP OAuth cannot be combined with username/password sources, and plaintext with SMTP OAuth requires TLS or SMTP CA bundle requires TLS. On a non-loopback host, the earlier general refusal is plaintext SMTP is allowed only on literal loopback for laboratory tests. Invalid IDs say smtp.oauth_tenant_id must be a UUID or smtp.oauth_client_id must be a UUID; an invalid mailbox says smtp.oauth_mailbox must be an email address. Invalid secret content says SMTP OAuth client secret must be a nonempty single-line value; invalid trust says SMTP CA bundle must contain valid PEM certificates. Private-file ownership and permission refusals remain the same as for password sources.

Runtime logs contain only stable classes: mail_oauth_token_request (endpoint, consent or credential rejection), mail_oauth_token_response (malformed/invalid response), mail_tls / mail_connection (including TLS handshake failures), or mail_rejected_permanent / mail_rejected_transient. Provider reply text, token bodies, secrets and SASL credentials never enter application logs. Check permissions, outbound HTTPS/SMTP and Exchange policy with IT; never paste tokens into evidence.

Local protocol and private-CA checks do not prove Microsoft 365 delivery. Before go-live, IT must request a code as an approved test administrator, confirm delivery and SPF/DKIM/DMARC/inbox placement, sign in, and repeat after token expiry. No Exchange tenant is bundled or simulated as a delivery qualification.

Certificates

By default, Caddy gets a public certificate through ACME. This needs the DNS record and ports from Before you start.

To use a certificate from your own CA instead, set tls.mode = "provided", then set certificate to a full-chain PEM file and key to its private key file. Keep both in a private, root-owned directory, with the key at mode 0600. The installer copies them to /etc/caddy/tls/ with root:caddy ownership and mode 0640 so Caddy can read them. You own renewal: before the certificate expires, replace the source files and rerun the same install command. For a private CA, install its root certificate in your users’ and collectors’ trust stores. Never disable certificate verification.

tls.mode = "internal" is for isolated labs only. It uses Caddy’s internal CA and works with localhost without public DNS. A lab may also send mail to an SMTP relay on 127.0.0.1 with tls = "none"; plaintext SMTP to any other host is refused. A lab install does not prove public certificates or real mail delivery.

Install

Run the installer from tach-package-VERSION, with the key you compared:

The installer prints stage names (never command arguments, credentials or first keys) while working. Package-list refresh is bounded to three minutes, host package installation to ten minutes, image conversion/load to three minutes each, and other install helpers to two minutes each. A stuck helper and its children are stopped with the failed stage named; fix that host/network cause and rerun the same install command. Existing data and first keys are preserved. Package setup is noninteractive and preserves existing package configuration files. Optional update/monitor schedulers are queued without waiting for their network jobs; install itself does not fetch channel metadata or send notices. Update checking starts two minutes after its timer is activated, not an already elapsed boot deadline. DNS, OAuth and SMTP for one operator notice share a hard 15-second wall deadline (in addition to socket/HTTP timeouts). A missing signed latest pointer means check unavailable, never an installation dependency.

sudo ./install.sh --config /root/tach-config.toml --public-key ../trusted-release.pub

The installer:

  1. checks the config,
  2. installs the Ubuntu packages it needs,
  3. checks the package signature again and loads the server image,
  4. creates the database and the first administrator in an empty data directory, owned by UID/GID 65532,
  5. starts one hardened container under systemd,
  6. configures Caddy for HTTPS,
  7. turns on the server’s nightly verified backup cycle at 04:30 UTC,
  8. checks that the server and local HTTPS both report the installed revision.

It ends with Installed. and the sign-in address, then any safety warnings; a warning never fails the install. If a step fails, see Troubleshooting.

The installer saves the first administrator’s ingest and query keys once, in /etc/tach/first-admin-keys.json (root-only, mode 0600). Move them privately to your secret store. Never print or share that file.

Rerunning install.sh with the same package and config keeps all data and the first keys, but ends existing sign-in sessions, so people sign in again. To move to a newer package, use tach upgrade (see Upgrade and roll back).

Check health

sudo tach status
sudo systemctl status tach-selfhost caddy

tach status exits non-zero unless both Tach on 127.0.0.1:8080 and Caddy’s HTTPS on 127.0.0.1:443 report the installed revision. Its error says which one failed and, for HTTPS, why the last attempt failed: nothing listening on 443, an untrusted certificate or one for another name, an HTTP error status, or a different revision. It also shows the last backup cycle’s result under backup, or pending before the first cycle, and exits non-zero when that cycle failed or is overdue (see Back up).

Safety warnings

A default install runs, but it is not yet safe to rely on. install ends with, and every sudo tach status repeats, one tach: WARNING [code]: ... line on stderr for each of these. The same codes are listed under warnings in the status JSON. A warning never blocks a command or changes its exit code. To clear one, edit your source config and rerun the installed package’s install command.

  • alerts_unset: updates.notify_email is empty, so nobody is emailed when a backup fails, a certificate nears expiry or the disk fills. See Operational notices.
  • backup_off_host_unset: neither backup.copy_target nor backup.azure_account with backup.azure_container is set, so every backup sits on the same disk as the database. See Other off-host targets.
  • backup_near_size_limit: the database file is at or above 80% of backup.max_mib (256 when unset). Past the cap, every nightly backup fails with backup_size_limit. Raise backup.max_mib; see Back up.

The installer’s HTTPS check proves the local service. It connects to Caddy on 127.0.0.1:443 with your domain as the TLS server name and verifies the certificate. It ignores DNS, proxy variables, load balancers and gateways, so split-horizon DNS, or a VM that cannot reach its own public address, does not fail a working install. To repeat the check by hand:

curl --noproxy '*' --fail --resolve YOUR_DOMAIN:443:127.0.0.1 https://YOUR_DOMAIN/healthz

For a private CA, add --cacert YOUR_CA_FILE. With tls.mode = "internal", Caddy’s CA file is readable only by root, so run:

sudo curl --noproxy '*' --fail --cacert /var/lib/caddy/.local/share/caddy/pki/authorities/local/root.crt --resolve YOUR_DOMAIN:443:127.0.0.1 https://YOUR_DOMAIN/healthz

The local check does not prove the public path. Check that from another machine on the network your users and collectors use:

curl --fail https://YOUR_DOMAIN/healthz

If a gateway or load balancer in front of the VM ends TLS with its own certificate, that command checks the gateway. Its certificate, routing and health probe are yours to configure and verify.

Compare the revision in /healthz with release.json. The /healthz version can lag the package version when a release changes only documentation or host scripts, so compare the revision.

Enter to openEsc to close