7 CLI Reference
vBlackOut edited this page 2026-08-26 07:48:04 +02:00

CLI Reference

ProxyAuth's binary doubles as its own management CLI. Running it with no subcommand starts the server normally; the subcommands below perform one-off setup/operational tasks and exit instead of starting the server.

proxyauth [COMMAND]

proxyauth prepare

First-time system setup: creates the proxyauth system user/group, and the directories ProxyAuth needs, with appropriate ownership and permissions. Must be run as root.

sudo proxyauth prepare
sudo proxyauth prepare --insecure   # see below

What it does, in order:

  1. Detects whether the OS is Alpine (uses addgroup/adduser) or Debian/Ubuntu-family (uses groupadd/useradd).
  2. Creates the proxyauth group if it doesn't already exist.
  3. Creates the proxyauth user if it doesn't already exist — a system account, no home directory, shell set to /usr/sbin/nologin (it's never meant to be logged into interactively).
  4. Creates /etc/proxyauth, owned proxyauth:proxyauth, permissions 750.
  5. Creates /opt/proxyauth/db (the LMDB revoked-token store — see Token Revocation & Multi-Instance Sync), owned proxyauth:proxyauth.

--insecure sets /opt/proxyauth to 777 instead of the default 700. This exists for specific containerized/dev setups where UID mapping between host and container makes strict permissions impractical — don't use it on a real deployment; the default 700 is what you want in production.

This is exactly what the official Docker image runs during build (RUN proxyauth prepare), and what you should run manually as your first step on a bare-metal/VM install.


proxyauth sync export

Exports this instance's build constants (used for cross-instance token compatibility) as a GPG-encrypted keypair, for distribution to other instances. Must be run as root.

proxyauth sync export

Produces key.asc and data.pgp in the current working directory. Full explanation, including why this is needed at all and how to distribute the files, is in SSO Across Multiple Instances.

proxyauth sync with no argument, or any value other than export, currently does nothing (Sync { target: None } and any non-"export" string both just exit 0 without action) — export is the only implemented sync operation today.


proxyauth db-add-user

Creates, updates, or revives a user directly in the database configured via databases in config.json (see Database-Backed Users). Requires a live connection to the database — refuses with a clear error if it's unreachable, rather than silently falling back to the local read-only cache. Fails with an error if databases isn't configured at all.

proxyauth db-add-user --username admin --password supersecret \
  --email admin@example.com --email admin-backup@example.com \
  --primary-email admin-backup@example.com

If --password is omitted, you're prompted for it interactively instead, with hidden input — nothing sensitive ever touches your shell history (the connectivity check happens before the prompt, so a down database is reported before you're asked to type anything):

proxyauth db-add-user --username admin
password: ████████████
User 'admin' written to the database (revived if it was previously soft-deleted).

The password is hashed with Argon2 (same as file-based users in config.json) before being written. If username matches a previously soft-deleted account (see db-delete-user below), it's revived — deleted is reset and the account becomes usable again, rather than remaining silently revoked underneath the "new" data. This command manages username/password/otpkey/email/must_change_password — allow/roles for a database user aren't yet settable from the CLI; add them directly in the user_allow/user_roles tables if needed.

This command is authoritative, not a merge — every flag reflects the account's complete intended state on that run, not a partial patch. Re-running it without --email clears any email(s) already on file; without --must-change-password, it clears a pending forced password change. Keep that in mind if you're scripting repeated calls.

Flag Description
--username (required) Login name.
--password Plaintext password to hash and store. Prompted interactively (hidden) if omitted.
--email Email address to notify this user at. Repeatable for more than one (--email a@x.com --email b@x.com). Omit entirely to clear any email(s) already on file.
--primary-email Which of the --email addresses is the primary one (used when sending a reset link via proxyauth reset-password). Must exactly match one of the --email values given. Defaults to the first --email if omitted.
--must-change-password Marks the account as needing a real password before normal use — their next successful login redirects to page_change_password instead of issuing a session. Use this when --password is a temporary one you're handing to someone directly. See Password Reset & First-Login Forced Change.

proxyauth db-delete-user

Soft-deletes a user in the configured database: the row is marked deleted (not removed) so every connected instance's incremental scan can pick it up and revoke the user immediately, without waiting for a restart or the slower full scan.

proxyauth db-delete-user --username bob
User 'bob' soft-deleted — will be revoked on the next incremental scan of every connected instance, and permanently purged after 86400s.

The row (and its user_allow/user_roles entries) stay in the database until databases.deleted_retention_secs elapses (default 24h), at which point they're permanently purged automatically — this window exists to give every instance a chance to notice the deletion, and to leave a short audit trail. Running db-add-user for the same username before the purge revives the account instead of creating a conflicting duplicate. Like db-add-user, this requires a live database connection and refuses with a clear error otherwise.


proxyauth db-restore-from-cache

Re-populates the configured database from this instance's local LMDB fallback cache (see config.json Reference § Local fallback cache) — the last known-good snapshot, mirrored there on every successful full read of the database. Meant for recovering from the database coming back empty (a botched restore, an empty database swapped in by mistake, etc.).

proxyauth db-restore-from-cache
  • Refuses if the local cache is empty (nothing to restore).
  • Refuses if the database already has any users, unless --force is given — this avoids silently overwriting real data with a snapshot that might be older than what's actually in the database right now.
proxyauth db-restore-from-cache --force

Never runs automatically — ProxyAuth can't distinguish a database that's accidentally empty from one someone emptied on purpose (e.g. compliance, decommissioning), so restoring is always an explicit, deliberate action.


proxyauth db-clear-cache

Clears this instance's local LMDB fallback cache.

proxyauth db-clear-cache

A no-op (not an error) if nothing was cached. The cache is repopulated automatically on the next successful full database read — this command doesn't disable caching going forward, it only wipes what's stored right now. Useful if you suspect the cached snapshot is stale or wrong and want to be certain a later database outage wouldn't fall back to it.


proxyauth db-sync-cache

Forces an immediate sync of the local LMDB fallback cache from the configured database — a live full read, right now, instead of waiting for the next scheduled full scan (databases.full_refresh_interval_secs, default 5 min). Useful right after fixing a database connectivity issue, to get a fresh cache immediately rather than waiting.

proxyauth db-sync-cache
Local cache synced from the database — now holds 12 user(s).

Requires a live database connection, like the other db-* commands — this must be a genuinely fresh read, never a fallback to the cache it's about to overwrite.

Refuses to overwrite a non-empty existing cache with an empty result — if the database answers but currently has zero users, that could be genuine, or it could mean something's wrong (wrong database selected, a permissions issue hiding rows, etc.):

Database returned 0 users, but the local cache currently has 12 — refusing to overwrite it with an empty snapshot without --force.
If the database genuinely has no users right now, re-run with --force.
proxyauth db-sync-cache --force

proxyauth reset-password

Resets a user's password: generates a single-use, time-limited link and emails it to them. Requires smtp and page_change_password to both be configured, and the user to have an email on file — see Password Reset & First-Login Forced Change for the full flow.

proxyauth reset-password --username alice
Password reset link sent to 'alice' at alice@example.com.

The user's current password keeps working until they actually follow the link and set a new one — this doesn't lock them out immediately, it just gives them a way back in without needing their old password.

Every prerequisite is checked up front, and every problem found is reported together in one run — rather than fixing one thing, re-running, and discovering the next problem only then:

'page_change_password' is not configured (checked the named --vhost, if any, then config.json) — nowhere to send the user.
'smtp' is not configured (checked the named --vhost, if any, then config.json) — cannot send an email.
User 'alice' has no email on file — add one to 'email' in config.json (or the database) before resetting their password this way.

Looks the user up in both file-based users and the database (whichever they live in) via the same combined_users() lookup used everywhere else.

--vhost: which smtp/page_change_password to use

proxyauth reset-password --username alice --vhost app.example.com

Both smtp and page_change_password can now be set per vhost (see routes.yml Reference § Per-vhost behavior overrides) — letting different domains send reset emails through different SMTP servers, with different destination pages. Since this command has no live HTTP request to resolve a vhost from automatically (unlike the browser-based flow), name it explicitly with --vhost when the target account's vhost has its own smtp/page_change_password you want used instead of the global default.

Omit --vhost to use the global config.json default, same as before this flag existed. An unrecognized --vhost (no route in routes.yml lists it) is an error, not a silent fall-through to the global config — naming a vhost is an explicit request for that vhost's settings, so silently using something else instead could send the email via the wrong SMTP server with no indication anything was off.


proxyauth reset-otp

Clears a user's TOTP/2FA secret, so they can re-enroll from scratch via /adm/auth/totp/get — for a lost authenticator device, or to revoke a possibly-compromised OTP secret.

proxyauth reset-otp --username alice

Only affects the one named user; every other account's OTP setup is untouched.

Hits the running server's own /adm/auth/totp/reset admin endpoint (the token_admin from config.json), rather than editing config.json directly — the reset has to update both the persisted config and the live server's in-memory state at the same time, or the old OTP secret would keep working until the next restart. See TOTP (2FA) Enrollment & Reset — Admin Guide for the full enrollment/reset flow this fits into.

This admin-mediated step can be bypassed entirely for a specific vhost with allow_totp_reenroll: true in routes.yml — letting a user re-enroll themselves with just their username/password, no admin needed. That's a real security trade-off, not a convenience feature; see routes.yml Reference § Self-service TOTP re-enrollment before enabling it anywhere.


proxyauth certbot renew

Renews a vhost's certificate right now, via the same native ACME mechanism the periodic certbot_renew: true scan uses — see Automatic Certificate Renewal (ACME) for the full mechanism.

proxyauth certbot renew app.example.com
proxyauth certbot renew app.example.com --force
proxyauth certbot renew all
proxyauth certbot renew all --force
Argument Description
<vhost> The vhost to renew, exactly as it appears in that route's vhost list in routes.yml — or the literal value all.
--force Renew even if the current certificate isn't due yet (still has more than renew_before_days left). Without it, a certificate that's not due is left alone and the command exits without contacting Let's Encrypt at all.

<vhost> must already have vhost_cert (cert/key paths) configured for it in routes.yml — certbot_renew: true does not need to also be set; running this command by hand is itself sufficient intent to renew, which also makes it usable for an "ACME certificates, manual renewal only, no periodic scan" setup.

all only touches vhosts that have both certbot_renew: true and a usable vhost_cert — unlike naming a specific vhost, all doesn't renew a vhost_cert-only vhost that never opted into automatic renewal; name it directly instead if you want that. Progress is printed live, one line per vhost, and a failure on one vhost doesn't stop the rest:

app.example.com: renewed
api.example.com: not due (58 day(s) left, renew_before_days: 30)
old.example.com: FAILED — currently valid certificate kept: <reason>

Exit code is 1 if any vhost failed, 0 otherwise. A failed renewal never touches whatever certificate was already valid — it keeps being served.


proxyauth certbot check

Prints certificate details for a vhost — read-only, makes no changes and contacts nothing external. Works for any vhost with a vhost_cert configured, whether it's ACME-managed (certbot_renew: true) or not — useful for checking a manually-managed certificate too.

proxyauth certbot check app.example.com
proxyauth certbot check all
app.example.com
  cert file:  /etc/proxyauth/cert/app.example.com/fullchain.pem
  subject:    CN=app.example.com
  issuer:     CN=R10, O=Let's Encrypt, C=US
  valid from: Jun  1 00:00:00 2026 +00:00
  valid till: Aug 30 00:00:00 2026 +00:00
  days left:  58
  serial:     03:a1:...
  covers:     DNSName("app.example.com")

all lists every vhost that has a vhost_cert configured, certbot_renew not required — this is deliberately broader than certbot renew all, since a read-only check is just as useful for a certificate ProxyAuth doesn't manage the renewal of.


proxyauth certbot new

Issues a certificate for a vhost that doesn't have one yet — unconditionally, no --force needed (there's no existing certificate to compare a renewal threshold against). Uses the exact same mechanism as renew; the difference is purely semantic (and it doesn't accept all — name the vhost you're setting up).

proxyauth certbot new app.example.com

vhost_cert must already be set for this vhost in routes.yml — same requirement as renew.

If this vhost was just added to routes.yml, a restart is still needed afterwards. The TLS layer's certificate file watcher for a given vhost is only ever set up once, at server startup, from whatever vhost_cert paths existed in routes.yml at that time. This command issues the certificate and writes the files correctly — it just can't retroactively make an already-running server start watching a path it didn't know about when it started. The command prints this reminder after a successful issuance.

See Automatic Certificate Renewal (ACME) § Before you turn this on for the full first-time bootstrap sequence (placeholder certificate, staging environment, port 80 reachability).


proxyauth routes-audit

Audits every route in routes.yml, showing exactly what secures it — an allow-listed username, groups, roles, or an explicit flag: ⚠ PUBLIC (required_login: false — no authentication at all) or ⚠ OPEN (login required, but username/groups/roles all left empty — any authenticated account gets through; see Group- and Role-Based Access Control for why that's the intended reading of "all empty", not a misconfiguration). Answers "where are we wide open?" at a glance across the whole route table.

proxyauth routes-audit
Route security audit

/admin -> http://10.0.0.5:3000
  required_login : yes
  secured by     : username [alice, bob] · groups [admins] · roles [superadmin]

/public -> http://10.0.0.6:8080
  required_login : no
  ⚠ PUBLIC — no authentication required at all

/internal -> http://10.0.0.7:9090
  required_login : yes
  ⚠ OPEN — no username/groups/roles configured: any authenticated account can reach this route

3 route(s) checked — 1 public, 1 open-to-any-authenticated-account, 1 restricted

Reads routes.yml and config.json directly — the server doesn't need to be running.


proxyauth check-access

Checks one account's access across every route — ✓/✗ per route and exactly why: matched username, a specific group, a specific role, an open/public route, or denied with what would need to change.

proxyauth check-access --username alice
Access check for 'alice'

✓ /admin      allowed — username explicitly listed
✓ /public     allowed — public route, no authentication required
✓ /internal   allowed — no restriction configured on this route
✓ /ops        allowed — member of group 'ops'
✗ /finance    denied  — requires username [bob] · groups [finance-team]

5 route(s) checked — alice can access 4, denied on 1

Doesn't require the account to already exist in config.json/the database — useful for "if I added alice with these groups, what would she reach?" before actually creating the account.


proxyauth check-routes

The combined, "everything at once" view: for every route, resolves the abstract username/groups/roles rule down to the concrete list of accounts that currently match it — each tagged with why — by checking every known account (file and database both). Also flags any route where that resolved list comes up empty: secured by something, but no current account actually satisfies it, so nobody at all can get in right now — almost always a typo in a group/role name, or an account that was renamed/removed after the route was written. routes-audit alone can't surface this, since it only describes the rule; it never resolves it against real accounts.

proxyauth check-routes
Global route / access overview
5 route(s) · 4 known account(s)

/admin -> http://10.0.0.5:3000
  required_login : yes
  secured by     : username [dave] · groups [admins] · roles [superadmin]
  reachable by (3) : bob (role 'superadmin'), carol (group 'admins'), dave (listed)

/finance -> http://10.0.0.9:9090
  required_login : yes
  ⚠ UNREACHABLE — secured by groups [finance-team], but no current account matches: nobody can get in right now

⚠ 1 route(s) nobody can currently reach: /finance
  (secured by a group/role/username that no current account actually matches — check for a typo)

All three of these commands call the exact same access-decision logic the running proxy enforces (AppConfig::route_access_decision, in config/config.rs) — not a separate re-implementation of it. That's deliberate: an audit tool that could silently disagree with what's actually enforced in production would be worse than no audit tool at all.

Output is colored on a real terminal, plain otherwise (piped to a file, | cat, etc.) or when NO_COLOR is set — see no-color.org.


proxyauth users / proxyauth groups / proxyauth roles

Three inventory commands — each lists every known instance of one thing (account, group, role), one small box-drawing diagram per entry, rather than a per-route or per-account cross-reference like the three commands above.

proxyauth users
Users (4 known account(s))

┌─ alice ──────────────────────────────────────────
│  groups  : ops
│  roles   : (none)
│  routes  : /public (public), /internal (open), /ops (group 'ops')  [3]
└───────────────────────────────────────────────────

┌─ dave ───────────────────────────────────────────
│  groups  : (none)
│  roles   : (none)
│  routes  : /admin (listed), /public (public), /internal (open)  [3]
└───────────────────────────────────────────────────
proxyauth groups
Groups (3 known)

┌─ admins ─────────────────────────────────────────
│  members : carol  [1]
│  routes  : /admin  [1]
└───────────────────────────────────────────────────

┌─ finance-team ───────────────────────────────────
│  members : (none — nobody currently belongs to this group)
│  routes  : /finance  [1]
└───────────────────────────────────────────────────
proxyauth roles
Roles (1 known)

┌─ superadmin ─────────────────────────────────────
│  holders : bob  [1]
│  routes  : /admin  [1]
└───────────────────────────────────────────────────

Notes:

  • groups/roles list every name currently referenced either by an account's groups/roles field or by a route's groups/roles list — the union of both, so a group only ever mentioned by a route (like finance-team above, likely a typo — see check-routes) still shows up, flagged as having no current members.
  • users' routes line and groups'/roles' routes line mean slightly different things: a user's routes are every route that user can currently reach, by any of the three mechanisms; a group's/role's routes are only the routes that list that specific group/role directly — not every route reachable by its members through some other path.
  • Same guarantee as routes-audit/check-access/check-routes: reachability is computed with the exact AppConfig::route_access_decision the live proxy enforces.

--list: flat, script-friendly output

Each of the three takes a --list flag that skips the boxes entirely and just prints one name per line — plain, never colored regardless of terminal/NO_COLOR, meant to be piped into something else rather than read directly.

proxyauth users --list
alice
bob
carol
dave
proxyauth groups --list
admins
finance-team
ops
proxyauth roles --list
superadmin

Useful for scripting, e.g. checking every current group against an external identity source:

for g in $(proxyauth groups --list); do
  echo "checking group: $g"
done

proxyauth stats

Reads live stats directly from the running instance over a local Unix domain socket (/opt/proxyauth/run/stats.sock) — no HTTPS round-trip, no admin token. RequestStats/active-session counts only ever exist as in-process memory in the running server; this socket, created by the server itself at startup, is what makes them reachable from this separate, short-lived CLI process at all. The socket's own filesystem permissions (0600, inside /opt/proxyauth, itself 0700) are the authentication — the same job token_admin does for the equivalent HTTPS endpoint, just without needing it for this specific, local-only path.

proxyauth stats
requests/sec (last):  42
avg req/sec (10s):     38.50
avg req/sec (60s):     35.20
total requests:        918273
active sessions:       7
uptime:                1d 1h 2m 03s

Notes:

  • Runs as run_user from config.json (switches to it automatically, requires the command itself to be launched as root) — defaults to the proxyauth user when run_user isn't set. Reads config from the standard /etc/proxyauth/config/config.json path.
  • The socket is created when the server starts, not before — if ProxyAuth isn't running yet, this command fails with a clear "is ProxyAuth running?" message rather than hanging.
  • For the same data over HTTP instead (e.g. from a monitoring system that isn't running locally), GET /adm/stats with the admin token is still available — see the Admin Routes Reference. This command is specifically the local, no-token-needed shortcut.

Running with no subcommand

proxyauth

Starts the server: installs the TLS crypto provider, ensures it's running as the proxyauth user, writes a sane default config.json/routes.yml locally if they don't already exist (a working /login + /private route example, and a starter set of users), loads configuration, and begins serving.

This default-generation behavior only ever creates a file that's missing — it never overwrites an existing config.json/routes.yml, so it's safe to run repeatedly and won't clobber your customized configuration.


Quick reference

Every command below marked "proxyauth (auto)" must itself be run as root — it then switches automatically to whichever user actually runs the server: run_user from config.json if set, otherwise the proxyauth user by default. This must be run as root, not as the target user directly, so it can read config.json (to find out what run_user even is) before dropping privileges.

Command Run as Purpose
proxyauth prepare root First-time user/directory setup
proxyauth prepare --insecure root Same, with relaxed /opt/proxyauth permissions (dev/testing only)
proxyauth sync export root Export build constants for multi-instance token compatibility
proxyauth db-add-user proxyauth (auto) Create/update/revive a user in the configured database
proxyauth db-delete-user proxyauth (auto) Soft-delete a user in the configured database
proxyauth db-restore-from-cache proxyauth (auto) Repopulate the database from the local LMDB cache
proxyauth db-clear-cache proxyauth (auto) Clear the local LMDB fallback cache
proxyauth db-sync-cache proxyauth (auto) Force an immediate cache refresh from the database
proxyauth reset-password [--vhost <hostname>] proxyauth (auto) Email a user a password reset link
proxyauth reset-otp proxyauth (auto) Clear a user's TOTP/2FA secret so they can re-enroll
proxyauth certbot renew <vhost|all> proxyauth (auto) Renew a Let's Encrypt certificate now, if due (or unconditionally with --force)
proxyauth certbot check <vhost|all> proxyauth (auto) Print certificate details (subject, issuer, expiry, SAN) — read-only
proxyauth certbot new <vhost> proxyauth (auto) Issue a certificate for a vhost that doesn't have one yet
proxyauth routes-audit proxyauth (auto) Show what secures every route in routes.yml
proxyauth check-access proxyauth (auto) Show what one account can reach, and why
proxyauth check-routes proxyauth (auto) Show who can reach every route right now, and flag unreachable ones
proxyauth users proxyauth (auto) List every account, its groups/roles, and reachable routes
proxyauth groups proxyauth (auto) List every group, its members, and which routes reference it
proxyauth roles proxyauth (auto) List every role, its holders, and which routes reference it
proxyauth stats proxyauth (auto) Print live stats from the local instance
proxyauth (no command) proxyauth (auto) Start the server

See also