A standby authenticator, and the backup I decided not to automate
My password manager was backed up nightly, but I had no independent copy of my TOTP secrets. They lived in one hosted account. If I lost access to that account or the service stopped working, I would lose those second factors together.
Ente Auth is an end-to-end encrypted authenticator whose server, museum, you can run yourself. So I ran one, as a cold standby: my phone keeps talking to the hosted service, and the self-hosted instance sits there holding a copy for the day that stops working.
The deployment was small. Most of the work went into understanding the configuration, fixing client issues, and deciding how to back up the secrets.
Running Auth with three containers
Ente's own compose file runs museum, Postgres, MinIO, a socat shim, and the web bundle. MinIO and socat exist purely for Photos: the authenticator stores its entities in Postgres and never touches object storage. A maintainer confirms you can skip it.
I checked the startup code in server/pkg/utils/s3config/s3config.go to see
whether museum could run without reachable object storage:
initialize()builds anaws.Configand asession.NewSessionper bucket, and never makes a network call. So no reachable S3 is needed.- But it ends with
viper.Sub("s3").Unmarshal(&config.fileDataConfig), andviper.Subreturns nil for a missing key. Calling a method on that panics. So ans3:key has to exist somewhere. - The image's own baked
configurations/local.yamlhas one, with empty values. That satisfies it.
My museum.yaml therefore needs no s3: block: the image’s default
configuration supplies it. Environment variables cannot supply this section
because viper.Sub does not consult AutomaticEnv.
services:
ente-museum:
image: ghcr.io/ente/server:<commit-sha>
restart: unless-stopped
ports:
- "127.0.0.1:8081:8080"
volumes:
- ./museum.yaml:/museum.yaml:ro
env_file:
- ./ente-auth.env
depends_on:
ente-postgres:
condition: service_healthy
ente-web:
image: ghcr.io/ente/web:<commit-sha>
restart: unless-stopped
ports:
- "127.0.0.1:3003:3003"
environment:
- ENTE_API_ORIGIN=https://auth-api.example.com
ente-postgres:
image: postgres:15.18
restart: unless-stopped
environment:
- POSTGRES_USER=ente
- POSTGRES_DB=ente_db
env_file:
- ./ente-auth.env
volumes:
- ./pgdata:/var/lib/postgresql/data
healthcheck:
test: pg_isready -q -d ente_db -U ente
130 MB of RAM across all three, under a gigabyte of images. The data is TOTP secrets, so it is measured in kilobytes.
Upstream publishes latest and per-commit SHA tags, without semantic version
tags or a changelog for each image. To pin an image, I resolve latest to a
digest and read the Git history between updates. That adds maintenance work to a
service I need to keep patched.
Secrets as environment overrides
museum reads config through viper with AutomaticEnv, prefix ENTE, and a
replacer turning dots and hyphens into underscores. So db.password becomes
ENTE_DB_PASSWORD, key.encryption becomes ENTE_KEY_ENCRYPTION, and so on.
I keep the four secrets in a mode-600 environment file, leaving museum.yaml
suitable for the configuration repository. Sharing the file between museum and
Postgres keeps the database password in one place. It also puts museum’s
encryption keys in the Postgres environment, which I accepted for this host.
key.hash is used to hash email lookups. Changing it makes existing user rows
unreachable, so it needs to remain stable with the database.
No SMTP, and the login code is in the log
I did not want a mail credential on this box. Ente handles that better than
expected. From server/pkg/utils/email/email.go:
if viper.GetString("smtp.host") == "" {
log.Infof("Skipping sending email to %s: %s", toEmails[0], subject)
and the verification email's subject is built as:
subject := fmt.Sprintf("Verification code: %s", ott)
So with no SMTP configured, the one-time code lands in the container log verbatim and the request returns success. Logging in from a new client is:
docker logs ente-museum --since 10m | grep -i 'Verification code'
This requires shell access to retrieve the code. For a standby I expect to use only a few times a year, that is acceptable and avoids storing an SMTP credential on the host.
The documented internal.hardcoded-ott setting uses a fixed verification code
for an address. I decided against it because the code would no longer provide a
one-time check.
Restricting access during registration
The initial registration needs to happen before the public instance is left unattended:
- With
internal.adminsempty, museum treats the first user to register as an admin. - A new certificate appears in Certificate Transparency logs within seconds, and scanners follow immediately.
Within five minutes of issuing the certificate for the new hostname, nginx had logged these probes:
GET /.env Go-http-client
GET /.git/HEAD Go-http-client
GET /?rest_route=/wp/v2/users/ leakix.net scanner
GET /debug/default/view?panel=config leakix.net scanner
GET / axios/1.16.1
So the order matters. Put an IP allow-list in the 443 blocks before enabling the
vhost, register the one account, set disable-registration: true, pin the real
user id into internal.admins, then remove the allow-list. Verify it took by
POSTing a signup request and expecting a 403 rather than trusting the config.
Without SMTP, someone reaching the registration endpoint still cannot read the verification code. museum also limits wrong attempts to 20 per code and active codes to 10 per hour. The allow-list adds another restriction while I create the account.
A footnote on allow-lists behind a CDN: allow sees the real client IP only if
you have set_real_ip_from for the CDN's ranges and real_ip_header pointing at
its client-IP header. Get that wrong and you lock out yourself and nobody else. I
also managed to allow-list the wrong address entirely by measuring my public IP
from the wrong machine. The reliable move is to read the denied request out of the
access log rather than guess.
Client and configuration issues
ENTE_API_ORIGIN needs a recreate, not a restart. The web image is plain
nginx serving ten prebuilt static apps, one per port. The API origin is not read
at runtime: an entrypoint script seds a placeholder out of the built JavaScript
on first start. Afterwards the placeholder is gone from the container's writable
layer, so docker restart silently keeps the old value. You need
up -d --force-recreate.
museum sets its own CORS headers. Its middleware reflects the request’s
Origin in Access-Control-Allow-Origin. Adding another value at the reverse
proxy causes browsers to reject the response, so the proxy must leave that
header to museum.
The web app cannot import codes. The docs do not say which clients can. The source does: the web auth app has no import route and no reference to one, while the Flutter client has parsers for plain text, Ente's own encrypted export, and a pile of third-party formats. So the browser is for reading codes only, and seeding the standby means using the mobile or desktop client. When you point that client at your instance, the endpoint field wants the API hostname, not the web app's.
Per-tab sessionStorage breaks two pages in a confusing way. Enabling TOTP
and changing your password both call ensureMasterKeyFromSession, which reads the
master key from sessionStorage. That is scoped to a single tab. The auth token,
however, lives in shared localStorage. So if you open /two-factor/setup in a
new tab, it authenticates fine and then throws at the crypto step, surfacing as
a generic "something went wrong".
In the server log, POST /users/two-factor/setup returned 200 with the user ID,
but the later enable call never arrived. Staying in the tab used to log in
avoided the client-side failure.
The backup I decided not to automate
I initially planned to automate the backup on the VPS.
Ente’s CLI can download authenticator entities, decrypt them, and export plain
otpauth:// URIs. I built a nightly job to export, encrypt, and upload them,
with checks for incomplete output.
Those checks mattered because fetchRemoteAuthenticatorData logs No data to export and returns nil, nil when it fetches nothing. The export command can
therefore write an empty file and exit successfully. My job rejected exports
with no otpauth:// lines, any unexpected lines, or fewer codes than the
previous archive.
Before running it, I reconsidered where it would store the credentials and removed the job.
The problem is what account add saves: the account token, master key, and
secret key, encrypted with a device key stored beside them. Someone with root
access to that host could use those files to decrypt the TOTP secrets without my
password. I did not want to add that capability to a public-facing VPS already
running my password manager and holding the age identity for other backups.
So backups are manual, into pass:
# plain-text export from the desktop client, saved under /tmp (tmpfs)
grep -c '^otpauth://' /tmp/codes.txt
pass insert -m ente/auth-codes < /tmp/codes.txt
pass git push
shred -u /tmp/codes.txt
pass show ente/auth-codes | grep -c '^otpauth://' # same count
pass already provides GPG encryption to a key on my hardware token and version
history through Git. I push it to a separate Git host, independent of the VPS
and the cloud storage used for its other backups.
I put the otpauth:// URIs directly inside pass, rather than wrapping an
Ente-encrypted export in it. That keeps recovery dependent on my GPG key without
adding a separate export password to remember.
Those URIs are the shared secrets themselves, so the file is equivalent to the
second factor for every account in it. Hence tmpfs and shred, not rm.
The drawback is that nothing warns me when the backup is stale. I need to repeat the export after adding or changing codes. I accepted that manual step to keep unattended access to the secrets off the VPS.
Then I turned the website off
I use the standby through the mobile or desktop client, so I normally leave the browser UI disabled:
ente-auth-web off # 404 for the web app
ente-auth-web on # serve it again
ente-auth-web status
Removing the nginx vhost would make requests fall through to another TLS server, potentially returning the wrong certificate. Instead, I keep the vhost and change how it handles application requests.
Instead the vhost's location / is a one-line include, and the script rewrites
that snippet between a proxy_pass block and return 404, runs nginx -t, and
reloads only if the test passes:
location / {
include /etc/nginx/snippets/ente-auth-web.conf;
}
Keeping the vhost means the certificate and the port-80
/.well-known/acme-challenge/ location both survive, so renewal keeps working
while the app is off. I checked that rather than assuming it: with the app off,
certbot renew --dry-run succeeded for both hostnames, and a token file dropped
into the webroot was still served over plain HTTP.
The disabled route returns 404. The app container keeps running on loopback, so I can restore access without restarting it.
Two things live only in the web bundle, so they need it on temporarily:
/two-factor/setup, which is the only route to enabling TOTP, and
/change-password. The desktop client covers the latter from its Account
settings.
A missing polkit agent
The desktop client showed “Authenticate to delete code” when I tried to remove a code, but no prompt appeared. I initially thought it wanted my Ente password.
On Linux the client gates destructive actions behind polkit, with an action set to
auth_self, meaning it wants your local user password. The package installs
the policy file correctly. What was missing was a polkit authentication agent,
so polkit had nothing to draw a prompt with, the authorization check returned
not-authorized, and the app fell through to:
if (!result) { showToast(context, infoMessage); return false; }
That text was the failure message from an authorization check. The app was not waiting for input.
My compositor configuration already included a command to start the agent, but I had never installed its package. The command had failed at every login. I had not noticed because my usual applications did not need polkit prompts.
I now check ps -eo comm,args | grep -i polkit when setting up a compositor
session. A missing agent can otherwise look like a failure in whichever app
first needs authorization.
Was it worth it?
For the codes, self-hosting barely moves the risk. Ente is end-to-end encrypted, so museum stores TOTP secrets encrypted under keys derived from your password. A server compromise, self-hosted or not, does not hand them over.
Self-hosting adds patching work, made less convenient by the lack of semantic version tags. It also puts another public-facing service on the same machine as my password manager. A host compromise would affect both.
I now have copies of the second factors in three separate places. The most
useful for recovery is the list of otpauth:// URIs in pass, which I can
import without relying on either Ente server.
If I were doing this again, I would make the pass export first. It provides
most of the recovery benefit with less upkeep. The standby is useful when I want
a phone client to read codes independently of the hosted service, but I would
put it behind a VPN or allow-list.