No description
  • Go 86.4%
  • templ 8%
  • JavaScript 4%
  • CSS 1.2%
  • Makefile 0.3%
  • Other 0.1%
Find a file
2026-11-17 00:21:35 -05:00
cmd/pubkeys audit logging 2026-11-15 13:55:44 -05:00
internal remove 'adoption' concept 2026-11-17 00:21:35 -05:00
.dockerignore MIT License 2026-11-13 21:49:58 -05:00
.env.example .env file support 2026-11-14 11:52:42 -05:00
.gitignore restructure, add more ui framework 2026-11-13 21:43:06 -05:00
Dockerfile MIT License 2026-11-13 21:49:58 -05:00
go.mod .env file support 2026-11-14 11:52:42 -05:00
go.sum .env file support 2026-11-14 11:52:42 -05:00
LICENSE MIT License 2026-11-13 21:49:58 -05:00
Makefile docker image prefix 2026-11-14 20:56:52 -05:00
package-lock.json MIT License 2026-11-13 21:49:58 -05:00
package.json MIT License 2026-11-13 21:49:58 -05:00
README.md remove 'adoption' concept 2026-11-17 00:21:35 -05:00

pubkeys

A developer public-key website built with Go, templ, HTMX, Tailwind CSS, and daisyUI. The index page publishes uploaded SSH authentication/signing keys, OpenPGP keys, age recipients, X.509 public certificates, minisign public keys, and WireGuard public keys, with filtering and sorting. Uploading, editing, and deletion remain protected by single-admin WebAuthn authentication.

The server and all UI assets compile into one statically linked binary. Node/npm and the templ CLI are build-time tools only: deployment needs no Node process, asset directory, CDN, or separate database server. Mutable private state is stored in an embedded SQLite database at DATA_DIR/pubkeys.db, using a pure-Go driver so builds remain static.

Authentication uses github.com/go-webauthn/webauthn for server-side validation, with no password login or public registration. Authenticator private keys stay on your device or security key.

GitLab remote hosts

On Remote host connections, select GitLab, enter https://gitlab.com or your self-managed HTTPS instance URL (not /api/v4), and provide a personal access token with the api scope. Provider credential encryption must be configured, as for other hosted connections.

GitLab connections support publishing, importing, and removing SSH authentication, SSH signing, and OpenPGP signing keys. New SSH keys are restricted to the selected role. GitLab does not accept the same SSH key twice, so publishing it for another role does not automatically broaden its permissions. An existing auth_and_signing key appears under both source roles; removing it deletes the whole remote key, including both uses.

Key generation tutorials

The public Tutorials page at /tutorials walks through local private-key generation and public-only export for every supported format: SSH, OpenPGP/GPG, age, minisign, WireGuard, and X.509. SSH certificates and X.509 CA creation have separate walkthroughs. Navigation selects one tutorial at a time using ordinary links (/tutorials?type=...); it works without JavaScript and only the selected walkthrough is rendered.

Examples recommend current cryptography and private-key protection, identify the exact public file to upload, and warn against publishing private keys. The GPG tutorial derives its preferred HKP(S) keyserver URL from the configured ORIGIN, including nonstandard ports, rather than the request's Host headers. GnuPG appends /pks/lookup itself. The X.509 guides cover creating a CRL-signing CA, obtaining its stable URL from this instance's admin details, publishing an initial signed CRL, and issuing a certificate with that CRL distribution point. All generation and signing happen locally; the tutorial page never generates or receives private keys.

Layout

cmd/pubkeys/main.go          # executable entrypoint
internal/
  server/
    server.go               # configuration, setup command, server lifecycle
    auth.go                 # routes, WebAuthn, sessions, request guards
    store.go                # private SQLite storage and process lock
    server_test.go          # HTTP/security integration tests
    certificates.go         # certificate upload validation and inventory
    certificates_test.go    # certificate upload/security regression tests
    keys.go                 # typed public-key upload and inventory storage
    keys_test.go            # full-format upload/security regression tests
    inventory.go            # metadata validation, stable IDs, stale-form checks
    inventory_handlers.go   # label/purpose editing and confirmed deletion
    inventory_test.go       # inventory management/security regression tests
    public.go               # public inventory mapping, filters, and sorting
    public_test.go          # public listing and publication-safety regressions
  publickeys/               # format parsers, normalization, fingerprints, purposes
  ui/
    keys.templ              # public-key form and HTMX purpose selection
    views.templ             # page and fragment components
    certificates.templ      # certificate upload form and inventory
    inventory.templ         # shared edit controls and delete confirmation
    public.templ            # public index, GET filter form, and results
    views_templ.go          # generated Go (checked in)
    generate.go             # pinned templ generator
    styles.css              # Tailwind/daisyUI CSS entrypoint
    assets.go               # go:embed declarations
    static/
      app.js                # browser WebAuthn integration
      htmx.min.js            # vendored HTMX
      HTMX-LICENSE.txt
      style.css             # generated CSS (checked in)
Makefile                    # build, generation, development, checks
Dockerfile                  # multi-stage build and non-root Alpine runtime
.dockerignore               # source-only Docker build context
package.json                # pinned build-only frontend dependencies
package-lock.json           # reproducible frontend dependency graph
bin/pubkeys                 # build output (ignored)
data/                       # private runtime state (ignored)

Build

Prerequisites: the Go toolchain required by go.mod, GNU Make, and a supported Node.js LTS release (22.14+ or 24 LTS) with npm. Initial dependency installation requires network access.

make             # generate templ + CSS, then build bin/pubkeys with CGO_ENABLED=0
make check       # regenerate, run Go tests, and go vet
make test-race   # race detector; needs CGO and a C compiler

make installs locked frontend dependencies with npm ci when needed, runs the pinned templ generator, compiles Tailwind/daisyUI, and embeds the results before building. All scripts and styles are served locally under /assets/, preserving the same-origin Content Security Policy. The build does not require globally installed templ or Tailwind executables.

Copy bin/pubkeys to the target host; it can run from any working directory without the source tree or node_modules. The default DATA_DIR is relative to that working directory, so use an explicit absolute path in production. Builds target the host OS/architecture by default; for example, GOOS=linux GOARCH=amd64 make build produces a Linux amd64 binary. Storage currently supports macOS and Linux.

Docker

Only Docker and Make are needed on the host; Go, Node/npm, and generated assets are handled inside the build stage:

make docker-build                         # image: pubkeys:latest
make docker-build IMAGE=pubkeys:dev        # optional image tag

The Dockerfile runs make build in a Go build stage, then copies only the statically linked binary into an Alpine 3.23 runtime with CA certificates. No compiler, Node runtime, npm dependencies, or source files are included in the final image. It runs as non-root UID/GID 10001:10001.

Start the server with a persistent volume, then create the initial enrollment link inside the running container:

docker volume create pubkeys-data
docker run -d --name pubkeys --restart unless-stopped \
  -p 127.0.0.1:8080:8080 \
  --mount type=volume,source=pubkeys-data,target=/data \
  pubkeys:latest

docker exec pubkeys pubkeys setup

Open the complete private enrollment link at http://localhost:8080. Runtime data must be persisted: without the volume, removing the container loses admin credentials and sessions. A new named volume inherits the image's /data ownership; existing volumes or host bind mounts must be writable by UID/GID 10001:10001 (keep the directory private, mode 0700). Only one server may use a data volume at a time; setup communicates with that server over a private local socket.

Inside the container, ADDR defaults to 0.0.0.0:8080 so Docker port forwarding works, and DATA_DIR defaults to /data. The host port above is bound to loopback only. For production, pass -e ORIGIN=https://keys.example.com when starting the server container, and use a trusted HTTPS reverse proxy. The setup command inside that container uses the running server's origin. If the proxy runs in another container, connect them through a private Docker network rather than publishing the backend publicly.

Structured logging

The executable writes newline-delimited JSON logs to stderr using Go's log/slog. Collect stderr with your service manager or container logging driver; logs are not stored in the application database or rotated by the application.

Every HTTP request, including rejected actions and local setup requests, produces an audit event. Events include method, route, path (without query strings), peer_ip, status, outcome, response bytes, and duration_ms. Public/admin inventory views and HKP lookups use event=key_view; key, archive, and revocation downloads use event=key_download; other requests use event=http_action. Inventory views, inventory downloads, and successful HKP lookups also include the selected resources as format:fingerprint identifiers. Remote execution also includes operations with the action and target connection ID, plus planned key fingerprints by role. These records describe attempted actions and responses served, not proof that a remote mutation succeeded or that a client read or saved a response.

When present, forwarded_for contains all X-Forwarded-For header values, separately from the transport peer IP. This header is untrusted client-supplied metadata unless your reverse proxy overwrites it; it never replaces peer_ip. Local Unix-socket setup requests have no IP address.

HTTP 4xx failures are logged at WARN, and HTTP 5xx, internal/render/write errors, and panics at ERROR. Internal errors include an errors field; HTTP rejections include the handler's failure message or a status description. Remote batch errors and partial import failures are logged as failed outcomes even when the endpoint returns HTTP 200. Request bodies, query strings, cookies, authorization headers, setup links, and key material are not captured. Protect access to logs and apply an appropriate retention policy: IP addresses, resource fingerprints, paths, and operational error details can still be sensitive.

Storage and backups

SQLite stores the administrator's WebAuthn credentials, session hashes and expirations, public keys, certificates, and revocation evidence in DATA_DIR/pubkeys.db. Inventory entries are stored as individual rows with JSON payloads; collection updates are transactional, and session expiration uses an indexed SQL query. Existing upload and inventory limits still apply.

The data directory must be on a local filesystem, private (0700), and writable by the runtime user. The database is restricted to 0600. Only one process may open the database at a time: the process lock is retained because administrator and WebAuthn ceremony state is cached in memory. When the server is running, the setup CLI requests a new link through the private DATA_DIR/.setup.sock Unix socket instead of opening the database. Schema initialization is automatic; unsupported schema versions are rejected. Legacy JSON files are not imported.

For a consistent backup, stop the server and copy the entire data directory, then restart it. Restore with the server stopped and preserve the private permissions and runtime ownership. Do not copy only the database file while the server is running, since SQLite may have an active journal. Treat backups as sensitive authentication data.

First-time setup

From this folder, whether the server is running or stopped:

make setup

This creates a private admin identity and prints a one-time enrollment link, valid for 15 minutes. It does not enroll a passkey itself. Treat the link as a secret: anyone who possesses it can enroll the first admin. The token is in the URL fragment (not sent in HTTP URLs), and only its SHA-256 hash is stored on disk.

If the server is not already running, start it:

./bin/pubkeys

Open the complete enrollment link printed by the setup command, then click Create admin passkey and follow your browser's prompt. Once enrollment succeeds, setup is disabled. You are signed in and redirected to /admin.

Use http://localhost:8080, not http://127.0.0.1:8080. The listen address is loopback, but the configured WebAuthn origin is http://localhost:8080. Origin and RP ID must remain consistent for your passkeys to work. Use a current Safari, Chrome, Firefox, or Edge with WebAuthn support and a user-verifying authenticator (device unlock or security-key PIN).

If the setup link expires before enrollment, run ./bin/pubkeys setup again with the same DATA_DIR; no restart is needed. This replaces the previous link. Setup refuses to run if an admin already has a passkey. If the service is still starting, wait for it to start and retry.

Daily use

  • Visit / to browse the public inventory; no account is required, even if the admin has not enrolled yet.
  • Choose Administration or visit /login, then choose Sign in with a passkey. Already-authenticated visitors to /login are redirected to /admin.
  • /admin, uploads, edits, deletions, and admin HTMX fragments require an authenticated session. The public index remains public even while signed in.
  • Choose Add a backup passkey while signed in to enroll another device or security key (maximum 10).
  • Choose Sign out to invalidate the server-side session and clear the cookie.

Register a backup passkey immediately. There is no password fallback, account recovery endpoint, passkey removal UI, or automatic reset. If all passkeys are lost, recovery requires deliberate local operator intervention. Do not simply delete admin.json: it would destroy the credential identity and should not be a normal recovery procedure.

Public index

/ displays a combined inventory of every uploaded public key and X.509 certificate. Existing uploads are public too: labels, purposes, fingerprints, algorithms, upload times, public certificate metadata, OpenPGP claimed identities/subkeys, and public material are visible to everyone. There is no per-entry private/draft setting. Admin passkeys, enrollment tokens, session data, edit revision tokens, and raw storage files are not exposed.

  • Search labels, format names, fingerprints, algorithms, purposes, and public metadata, case-insensitively (up to 200 characters).
  • Filter by format and/or purpose. Filters combine with the search; incompatible combinations simply show no matches.
  • Sort by label, format, or upload date, ascending or descending. The default is label ascending, with deterministic tie-breaking. Sorting does not reorder stored records.
  • Use View public material to select and copy a usable public export. X.509 certificates are shown as PEM, OpenPGP as ASCII-armored public keys, and the remaining formats as their normalized public text. This is not an ownership, trust, validity, or revocation check.
  • Filters are normal GET parameters, so filtered views can be bookmarked or shared and work without JavaScript. HTMX updates the results in place when JavaScript is enabled and keeps the URL in sync. Reset returns to the unfiltered index.

For example:

/?format=ssh&purpose=signing&sort=label&order=asc
/?q=developer&format=x509&sort=uploaded&order=desc

Supported format values are ssh, openpgp, age, minisign, wireguard, and x509. Purpose values are authentication, signing, encryption, and certification. Empty format/purpose values select all; invalid or repeated filter parameters return a 400 error. Edits and deletions are reflected on the next public request; deleting an entry does not retract copies already made by visitors.

Public downloads

Individual entries are available without authentication at /entries/<format>/<label>.<extension>. Labels match exactly (case-sensitive) after trimming on upload/edit; URL-encode spaces and other special characters. Labels must be unique within each format, but can be reused across formats. Renaming an entry changes its download URL.

Format Example URL
SSH /entries/ssh/Work%20key.pub
OpenPGP /entries/openpgp/Work%20key.asc
age /entries/age/Backups.txt
minisign /entries/minisign/Releases.pub
WireGuard /entries/wireguard/Laptop.pub
X.509 /entries/x509/Signing.pem

GET /entries downloads entries.zip containing the default public selection, excluding revoked, retired, compromised, and expired entries. The same q, format, purpose, sort, order, and status-inclusion parameters as the public page filter and order archive entries:

curl -fOJ 'https://keys.example.com/entries/ssh/Work%20key.pub'
curl -f -o signing.zip 'https://keys.example.com/entries?purpose=signing&sort=label&order=asc'
curl -f -o certificates.zip 'https://keys.example.com/entries?format=x509'

The public page's download icons use these individual URLs, and Download ZIP downloads the currently displayed selection. Both work without JavaScript. Exports contain only public material: OpenPGP ASCII armor, X.509 PEM, and normalized text for the remaining formats; no admin records or metadata manifests are included.

ZIP files use format folders such as ssh/Work key.pub. Download filenames replace unsafe filesystem characters and shorten long labels. Collisions (including case-only differences, sanitized labels, or older duplicate labels) get stable fingerprint-derived suffixes so files never overwrite each other. Empty selections produce a valid empty ZIP; invalid/repeated filters return 400, missing individual entries return 404, and ambiguous older same-format labels return 409 until renamed. Existing duplicates are not renamed automatically.

OpenPGP keyserver lookups (HKP/HKPS)

The public, read-only GET /pks/lookup endpoint supports GnuPG key retrieval, refresh, and search. Use hkps:// when deploying behind HTTPS (the recommended setup); it uses the existing HTTPS listener on port 443 by default. For local plain HTTP, use hkp://localhost:PORT with the backend's explicit port. No separate keyserver service is required.

gpg --keyserver hkps://keys.example.com --recv-keys FINGERPRINT
gpg --keyserver hkps://keys.example.com --refresh-keys FINGERPRINT
gpg --keyserver hkps://keys.example.com --search-keys 'alice@example.com'
  • op=get returns matching ASCII-armored public keys with content type application/pgp-keys.
  • op=index and op=vindex return the same machine-readable HKP index (info, pub, and percent-encoded uid records). options=mr and fingerprint=on are accepted; HTML indexes and signature listings are not provided.
  • search accepts full primary/subkey fingerprints (40 or 64 hexadecimal characters), long or short key IDs (16 or 8 hexadecimal characters), optionally prefixed with 0x, or a case-insensitive user-ID substring. exact=on matches the full user ID or email address rather than a substring. Searches use OpenPGP identities, not inventory labels.
  • Every matching key is returned, including when a short key ID is ambiguous. Prefer full fingerprints and verify them through a trusted channel; search results do not establish trust or ownership.
  • Lookups include revoked, expired, retired, and compromised stored keys regardless of the normal public-list filters. Retained revocation evidence is merged into retrieved exports, and indexes flag revoked/expired keys. Renaming an inventory label does not change fingerprint-based lookup.
  • Invalid queries return 400; searches with no matches return 404. Public submissions (/pks/add), keyserver synchronization, and WKD are not implemented. Uploads and revocation publication remain admin-only.

GnuPG must explicitly fetch or refresh a key to learn of a newly published revocation. Hosting it here does not notify existing key holders or update other keyservers automatically.

GitHub and Forgejo connections

From Administration → Remote host connections, configure one connection per account/host. Multiple connections to the same host and multiple Forgejo hosts are supported. Connections are private to the admin; they do not appear in the public inventory.

Credential encryption

Set PROVIDER_ENCRYPTION_KEY to a base64-encoded, randomly generated 32-byte key before starting the server. For example, generate a value once using openssl rand -base64 32, then supply it through your deployment's secret/environment configuration. Do not generate a new value on every startup or commit it to source control. For Docker, inject the same value into each replacement server container.

Provider tokens are encrypted using AES-256-GCM in SQLite, bound to their connection ID, provider, host, and verified account. The deployment encryption key is separate from the database and unrelated to admin passkeys. Back it up separately and securely: losing it requires re-entering provider tokens. Backups of the database plus this key expose provider credentials. Encryption at rest does not protect tokens from a compromised running server. A missing key disables provider setup and actions without disabling the existing public inventory; malformed configured keys prevent startup. To deliberately replace the encryption key, re-enter every connection's token under the new key—automatic key rotation is not provided.

Configure and publish

  1. Add a label, provider, HTTPS instance URL (not an API endpoint), and personal access token. Forgejo instances mounted under a subpath and GitHub Enterprise instance URLs are supported. GitHub.com uses https://github.com.
  2. Test and save connection verifies the authenticated account. Replacing a token must authenticate that same account. Use only trusted hosts: the server makes outbound requests to the configured host, including private-network hosts. HTTPS certificates are verified and redirects are refused.
  3. Select up to five key/role entries and Review push. GitHub supports separate SSH authentication, SSH signing, and GPG signing APIs. Forgejo supports SSH authentication and GPG signing; separate SSH-signing publication is explicitly unavailable pending version-specific support. Unsupported roles are never mapped to another role.
  4. Review the account, host, fingerprints, and actions, then confirm with a fresh passkey check. This does not reuse your login as approval: the required-user-verification assertion is session-bound, single-use, expires with the two-minute review, and authorizes only that batch. Changes to connection/inventory state require a new review.

For GitHub classic PATs, grant the relevant key-management scopes: admin:public_key, admin:ssh_signing_key, and/or admin:gpg_key. Fine-grained tokens need the corresponding user-account key permissions with write access. Forgejo tokens need the appropriate read/write user permissions for the instance version. The connection test verifies identity, not every mutation permission; insufficient permissions are reported when publishing/removing. Stored tokens are never redisplayed.

Only active, unexpired, non-revoked keys with the matching inventory purpose are offered. SSH certificates are excluded. OpenPGP publication uploads the whole public identity, including public subkeys, armored for the provider; purpose labels do not independently verify signing capability. Providers may apply additional identity/algorithm restrictions.

Publishing checks full fingerprints and avoids duplicate keys. Matching pre-existing remote keys are not duplicated. Successful publications record remote IDs. Remove remote keys reviews and deletes selected keys after verifying remote IDs and fingerprints again. Recorded publications remain available for cleanup after local key deletion. Remove recorded remote keys before deleting a connection.

Local retirement, revocation, deletion, or deselection does not automatically remove remote keys. There is no background synchronization: every remote push/removal batch needs explicit passkey approval. The last approved push selection and latest batch results are retained per connection.

Batches stop on the first provider failure and can partially succeed; completed actions are persisted individually. Check results before retrying, and review a new batch with fresh passkey approval. Timeouts, process crashes, or storage errors after a provider accepted a request can leave an uncertain outcome. Inspect the remote account manually in that case. A key whose creation succeeded remotely but whose publication could not be recorded will not be duplicated or deleted on push retry; use the inventory's live host check to review removal. Keep SQLite backups current: restoring old publication records cannot roll back remote actions. No checks have been made against your live accounts.

Import existing remote keys

Under a connection, choose a Source role in Import existing remote keys, then Preview remote keys. The preview verifies the connection account and makes only read requests to the provider. Select the desired entries, adjust labels, and confirm that their public keys and metadata will become publicly visible in this site's inventory.

Imports copy a five-minute, session-bound snapshot and update only local inventory. An authenticated admin session is sufficient—fresh passkey approval remains mandatory for remote pushes/removals, not these local-only imports. Successful previews for the same connection replace that session's previous preview; changing the connection requires a new preview. Submitted key material is never trusted from the browser.

SSH authentication and signing sources map to the corresponding local purposes. Existing keys are deduplicated by format and fingerprint: missing source purposes are added, while existing labels, public material, lifecycle, and timestamps are preserved. Importing does not refresh an existing OpenPGP export or reactivate retired/revoked keys. Newly imported keys use editable remote titles when valid, or a fallback label. Label collisions must be resolved before import. Existing remote copies are left unchanged. Imported keys otherwise behave like directly uploaded keys: matching remote copies can be removed after a live host check and fresh passkey approval, without a separate ownership step. The exception is SSH-host ~/.ssh/*.pub files, which are read-only import sources and can never be removed by this application.

GPG imports require a complete public export, including the identity and public subkeys supplied by the provider. If listing provides only a primary-key packet, the importer tries the authenticated GPG detail endpoint and verifies its ID and fingerprint before accepting a complete export. If no complete export is available, the entry is marked unavailable; upload a full public export manually instead. SSH certificates are not importable. Role availability is the same as for publishing, including the current Forgejo SSH-signing limitation.

A preview supports at most 100 remote entries for the chosen role, with at most eight outstanding previews globally. Existing inventory limits still apply: 32 KiB per key, 100 stored keys, and 3 MiB serialized key storage. The full selected batch is validated before changing the inventory; duplicate-only imports are allowed at the key-count limit. Existing OpenPGP revocation evidence is applied to newly imported keys, and imported verified revocations are retained just as with uploads.

SSH remote hosts

SSH remotes use public-key authentication, not OpenSSH CA-signed certificates. Set PROVIDER_ENCRYPTION_KEY as described above, then visit Remote host connections to generate the application's persistent authentication identities. Private keys are encrypted with AES-256-GCM in a separate SQLite collection. Preserve both the database and the deployment encryption key: losing or replacing that key prevents SSH authentication; identities are not silently regenerated. Automated identity rotation is not implemented.

The application tries these key types in order: Ed25519, ECDSA P-256, then RSA-3072. Obsolete DSA and RSA/SHA-1 authentication are not enabled. Install only the preferred supported public key on each host. Dedicated public downloads (available without login after generation) are:

  • /ssh/keys/ed25519.pub
  • /ssh/keys/ecdsa.pub
  • /ssh/keys/rsa.pub

These identities are not inventory entries or part of /entries downloads. Remote import previews also exclude the application's own authentication keys.

Connect and transfer keys

  1. Download an application public key and manually install it in the remote user's ~/.ssh/authorized_keys using an existing trusted login. This bootstraps access; the application does not accept passwords or external private keys. Use directory/file permissions 700/600.
  2. Add an SSH connection with a label, hostname (optionally :port, default 22; use [IPv6]:port for IPv6), and username. Supply the server's public host key in OpenSSH public-key format, for example the contents of /etc/ssh/ssh_host_ed25519_key.pub, obtained through a trusted channel. Do not blindly trust ssh-keyscan output. The pin is verified on every connection, and no accept-any/TOFU fallback is used.
  3. Preview remote keys pulls SSH public keys from ~/.ssh/*.pub, or exports OpenPGP public identities and subkeys using the remote user's default GnuPG keyring. Select and confirm imports as for Git providers. Private SSH keys and GPG secret-key exports are never requested.
  4. Review push installs eligible SSH authentication keys into authorized_keys (preserving existing entries and avoiding duplicates), or imports complete OpenPGP public keys with gpg --batch --no-tty --import. Each push requires the existing fresh passkey approval. GPG ownertrust is not changed.

SSH hosts must provide a Unix/POSIX shell and standard cat, awk, mkdir, chmod, mktemp, mv, and rm utilities; GPG operations additionally require gpg installed on the remote. The application server itself does not need an SSH or GPG executable. The default remote GnuPG configuration/home is respected. SSH certificates and separate SSH-signing publication are not supported. Standard SSH remotes also support Review removal for SSH authentication keys matching inventory keys, including pre-existing entries and older untracked pushes. Removal requires fresh passkey approval, verifies the remote fingerprint, and removes all entries for that key from ~/.ssh/authorized_keys, including entries with options. Other keys and comments are retained. The original ~/.ssh/*.pub files are never modified or removed, even when the same key is removed from authorized_keys. GPG removal is not supported. Plugins require a remove command as described below. Deleting a connection never removes installed keys.

Only configure trusted hosts and accounts: connections originate from the server and can reach private networks. Remote output is bounded and operations have deadlines. Batches can partially succeed or time out after a mutation; inspect the host before retrying. Public-key import limits and inventory lifecycle eligibility are unchanged.

Custom SSH host plugins

For devices such as VyOS that manage authorized keys through configuration commands, create DATA_DIR/ssh-plugins/<name>.json on the application server (create the directory if needed). Enter <name> in the SSH plugin field when adding an SSH connection. The same plugin can be used by multiple hosts and accounts. Names contain only letters, digits, _, and -, start with a letter or digit, and are at most 64 characters.

For example, DATA_DIR/ssh-plugins/vyos.json can delegate to administrator-installed helpers on the router:

{
  "list": "/config/scripts/pubkeys-list",
  "add": "/config/scripts/pubkeys-add {{label}} {{key}}",
  "remove": "/config/scripts/pubkeys-remove {{label}} {{key}}"
}

These helpers are examples of your own scripts, not built-in VyOS commands. Implement them using the configuration interface supported by your VyOS version:

  • list runs remotely without stdin and must print one standard OpenSSH public key per line (ssh-ed25519 AAAA... optional-comment). Convert device-specific configuration output into this format. Return a nonzero exit status on any read failure; do not print partial results as success. Empty output means no keys. The command is also used for the connection test, so it must be read-only and safe to repeat.
  • add receives the inventory label and one validated, canonical public key through the placeholders below. The key is also available on stdin with a trailing newline (key type and base64 data, no comment). Add only that key, preserving all other keys, including the application's login key, and treat an already-installed key as success.
  • remove is optional and receives the same label originally used for the managed push plus the verified remote public key, using the same placeholders and stdin format as add. Remove only that key, preserve other keys, and return nonzero on failure. Removal is available for matching inventory keys while the plugin supports removal, including pre-existing keys and older untracked pushes. Removal is reviewed and requires fresh passkey approval. The remote fingerprint is checked before execution, and removal still works if the local inventory entry has been deleted.

Both add and remove support {{label}} and {{key}} anywhere a complete POSIX shell word is expected. Each value is automatically single-quoted with embedded quotes escaped, so whitespace, quotes, newlines, $(), and backticks in labels remain data. Do not surround placeholders with your own quotes or embed them inside another shell's -c string. Replacements are not recursively expanded. {{key}} is the canonical type base64 public-key line without a trailing newline; {{label}} is the exact label, not a sanitized device identifier. Validate or map labels to identifiers suitable for your device; shell quoting does not make arbitrary labels valid CLI identifiers or safe file paths. Use the device CLI's end-of-options separator where available and do not eval these values.

No helper needs to be installed: add and remove can contain entire inline shell scripts, with newlines encoded as \n in JSON. For example, begin an inline command with set -eu; label={{label}}; key={{key}}; and then use "$label" and "$key" in your device-specific commands. For VyOS, the script must handle configuration session setup, public-key identifiers, commit and save, and exit nonzero if any step fails. Updates are per key, not whole-keyset replacement; serialize configuration changes where the device requires it.

Commands (after add/remove placeholder expansion) are sent through SSH exec without a PTY and must be noninteractive. They run as the connection's SSH username, not on the application server. A remote wrapper script is useful when a device's configuration CLI requires special shell/session setup. Public-key authentication still needs to be bootstrapped through the device's supported configuration mechanism. Host-key pinning, output limits, timeouts, and push approval requirements remain in effect. A timed-out update may already have committed: inspect the device before retrying.

Plugin files are trusted executable configuration: restrict write access to deployment administrators. The application never accepts plugin commands from the web form. Files must be JSON objects containing required nonempty list and add commands and an optional remove command, at most 64 KiB total. Omitting remove or leaving it blank disables removal. They are loaded for each operation, so no restart is needed; missing or invalid selected plugins fail closed rather than falling back to standard host commands. Avoid changing plugins while reviews or transfers are in progress.

Plugins customize SSH authentication keys only. OpenPGP operations retain the standard remote gpg commands and should only be used on hosts that support them. Import previews use the plugin's list output instead of scanning ~/.ssh/*.pub; remote checks use the same list. Leaving the plugin field blank preserves standard SSH behavior. Removal requires a plugin with a nonempty remove command and applies only to SSH authentication keys.

Lifecycle, revocation, and expiry

Every entry has an independent operator lifecycle: Active, Retired, or Compromised, managed in its admin Status controls. Lifecycle changes never erase or undo verified revocation evidence. A revoked entry may also be marked retired or compromised. Existing records default to active without migration.

Both / and ZIP downloads at /entries exclude revoked, retired, compromised, and expired entries by default. Opt in using the filter checkboxes or these GET parameters (each accepts 1/0 or true/false):

/entries?include_revoked=1
/?include_expired=1&include_retired=1
/entries?include_revoked=1&include_compromised=1&include_expired=1&include_retired=1

An entry in multiple excluded categories requires every applicable switch. Expiry is evaluated at request time for X.509 certificates, SSH certificates, and OpenPGP primary keys with verified key-expiry self-signatures. Missing or stale revocation evidence is unknown, not evidence of non-revocation. Unknown entries are not excluded by default. Direct /entries/<format>/<label>.<extension> URLs remain available regardless of status; hiding an entry from browsing is not a privacy control or a way to retract existing copies.

OpenPGP

Use the entry's Status form to publish a standalone self-issued primary-key revocation certificate or an updated public export containing one. The signature must verify against the stored primary key. Verified revocation signatures are merged into the existing public export while preserving its fingerprint, identities, and subkeys; its existing download URL then distributes the revoked export. Proof is also retained independently in the evidence store, so deleting and re-importing the same primary key cannot erase its published revocation. This also applies when a newly uploaded public export is already revoked. Upload limits remain 32 KiB and 256 packets for the resulting key.

Publishing revocation is irreversible. Designated-revoker signatures, arbitrary key-material refreshes, and subkey-only revocation updates are not supported by this workflow and are rejected rather than treated as primary-key revocation. A GPG-generated .rev file may include explanatory text and a protective colon before the armor: deliberately remove the explanation/safety prefix and upload only the revocation block when ready to publish it.

X.509 CRLs

In Revocation management, upload one DER or PEM (X509 CRL) full, direct CRL and its issuing CA certificate. The site checks the CRL signature, CA/CRL-signing authorization, issuer/authority-key association, freshness, and applicability to each stored certificate. A matching certificate must itself verify under that issuer key. This does not establish root-chain trust or perform OCSP checks.

Fresh applicable CRLs can establish current list coverage. Once a valid list establishes permanent revocation, a subsequently stale CRL does not undo that evidence; stale clean coverage becomes unknown. Delta, indirect/scoped CRLs, unsupported critical extensions, and reversible certificateHold/removeFromCRL entries are rejected explicitly.

Stable CA CRL distribution points

An uploaded CA certificate with CA:true and cRLSign shows its full stable CRL URL in its admin Details, even before a CRL is published:

https://keys.example.com/revocations/x509/<issuer-id>.crl

The issuer ID is a SHA-256 hash of length-framed DER subject name and public-key information. Same-name, same-key CA certificate renewals retain the URL; changing the encoded name or key creates a different URL. Labels and certificate fingerprints do not determine this identity. Keep old issuer URLs reachable for certificates issued under old keys. Uploading a CA does not establish trust or generate a signed CRL: until the first signed full CRL is uploaded, the endpoint returns 404 with no-store caching. CRLs may also be published without an inventory CA entry; their uploaded issuer certificates are retained independently. Deleting an inventory entry does not remove its CRL publication.

Create and sign CRLs externally, then upload the CRL and issuer certificate in Revocation management. Put the stable URL in the CRLDistributionPoints extension of certificates issued by that CA (an intermediate CA's own certificate instead references its parent's CRL). Existing certificates cannot be modified without reissuance. The endpoint serves DER as application/pkix-crl, supports unauthenticated GET/HEAD and ETag conditional requests, and caches for at most five minutes, bounded by nextUpdate. Clients must enable revocation checking and enforce the signed freshness window. Choose HTTP/HTTPS according to client support and deployment policy; CRLs are signed independently of their transport, and HTTPS can introduce certificate-validation dependencies.

Numbered CRL streams use increasing CRL numbers with nondecreasing thisUpdate; unnumbered streams use thisUpdate. Older consistent lists are retained as evidence without replacing the current list. Identical CRL reuploads are idempotent. Conflicting same-number lists, conflicting same-time unnumbered lists, contradictory number/time ordering, and mixing numbered with unnumbered lists for one issuer are rejected. Original /revocations/<digest>.crl evidence URLs remain unchanged. No storage migration is needed: publication metadata is derived from existing records. If legacy records already contain an ambiguous stream, only that issuer's stable endpoint returns 503; historical downloads and other issuers remain available, and the CA details report the conflict. Such legacy conflicts require operator review of the retained evidence store; do not discard permanent revocation evidence merely to select a publication.

Renew and re-upload before nextUpdate, even if nothing new has been revoked. CA details show the current number, signed update times, and missing/current/expiring-soon (within 24 hours)/stale status. A stale latest list remains downloadable with immediate revalidation; the endpoint never rolls back to an older list just because that list has a later expiry. There is no signing service, remote refresh, OCSP service, or out-of-band expiry notification.

SSH KRLs

Import unsigned OpenSSH KRLs in Revocation management, or use an SSH entry's Revoke in SSH KRL action to generate administrator-trusted revocation policy. Supported imports cover explicit public keys, SHA-1/SHA-256 key fingerprints, CA-specific/wildcard certificate serial lists/ranges/bitmaps and key IDs. Revoking an underlying public key or signing CA also affects matching certificates. Unsupported critical extensions and legacy embedded signature sections are rejected; no KRL signature-authentication claim is made.

The public Combined SSH KRL at /revocations/ssh.krl combines all explicitly generated revocations and the complete scope of every imported list, including key/certificate identities never present in this inventory. It copies verified-format sections without expanding serial ranges or bitmaps. Deleting or re-importing inventory entries never removes this retained policy. Original imported KRLs also remain downloadable individually. Nonzero-serial certificates are generated as CA/serial revocations; serial-zero certificates revoke their underlying key, which also affects other certificates using that key. Consumers must explicitly configure/download the KRL; SSH clients and servers do not automatically discover it here.

Original CRLs/KRLs and retained revoked OpenPGP public exports are publicly downloadable via the evidence links under Revocation lists. Evidence is uploaded by the admin only: there is no automatic remote fetching, background refresh, or private-key signing service. CRLs need periodic re-uploading before nextUpdate to retain current coverage. Limits are 256 KiB per list, 32 KiB for the issuer certificate, 1 MiB per list-upload request, 256 evidence records, a combined KRL bound of 4 MiB/10,000 sections, and 3 MiB serialized evidence storage in private DATA_DIR/revocations.json. Revocation evidence has no removal/undo UI. Back it up together with the key and certificate records.

Public-key uploads

Sign in to /admin, choose a format under Add entry, enter a label, and upload a public file. Purposes are inferred by the server when the format or public metadata determines them. Only plain SSH keys require intended purposes; X.509 certificates offer fallback purposes when their usage metadata cannot be mapped. The format selector updates the guidance using HTMX.

Format Accepted public material Intended purposes
SSH One OpenSSH .pub line, including supported SSH certificates; no authorized_keys options or multi-line files Choose authentication, signing, or both for plain keys; certificates automatically use authentication
OpenPGP One armored or binary public identity with its public subkeys; no secret packets, compressed packets, or multi-key keyrings Automatically detected from signed primary-key/subkey usage flags; legacy keys without flags use algorithm capabilities
age One native X25519 or hybrid recipient, or an SSH RSA/Ed25519 recipient; no secret identities or external-plugin recipients Encryption (automatic)
minisign A .pub file with its optional untrusted-comment line, or the base64 public-key line alone Signing (automatic)
WireGuard One padded base64 public key (32 bytes), not a config file Authentication and encryption (automatic)

WireGuard warning: public and private keys have the same encoding, so no parser can reliably tell them apart. Upload only a known public value (for example, output from wg pubkey), and explicitly confirm it is public in the form. Recognizable secret/private formats for other key types are rejected; the WireGuard limitation is unavoidable.

  • Uploads and purpose fragments require an authenticated admin session. Mutations retain the existing same-origin protection. Each file is limited to 32 KiB, and the whole multipart request to 64 KiB. OpenPGP exports are additionally limited to 256 packets.
  • Normalized public material, labels, purposes, fingerprints, and upload timestamps persist in private DATA_DIR/keys.json, using atomic writes and 0600 permissions. The new inventory is limited to 100 keys and 3 MiB of serialized data, separately from the existing X.509 inventory. Existing certificate records need no migration; public-key uploads do not rewrite certificates.json.
  • The page displays format, algorithm, purposes, fingerprint, upload time, and format-specific metadata. SSH uses the usual SHA-256 fingerprint; OpenPGP uses the primary key's native fingerprint; the remaining formats use a SHA-256 digest of their normalized representation. Claimed identities and certificate metadata are not evidence of ownership or trust.
  • Comments/armor do not create distinct keys. Duplicate imports within a format are rejected, including an OpenPGP export with the same primary key. Use Edit label and purposes to change metadata after upload. The same SSH key may be stored separately as an age recipient because those are different formats/usages.
  • Upload purposes use format capabilities or signed OpenPGP usage flags where available, independently of expiry and revocation status. Manual purpose labels remain organizational, and inventory edits are unchanged. Purposes do not establish trust, possession of secrets, current validity, revocation status, or compatibility with a relying party's policies. Existing entries are not automatically relabeled.
  • Uploaded public material and metadata are published immediately on /. Only admin users can edit labels/purposes or delete entries. Public downloads are available under /entries; only verified revocation updates may modify stored OpenPGP material, not arbitrary key refreshes. Never upload private keys.

X.509 certificate uploads

Sign in to /admin and choose the X.509 format under Add entry to upload a labeled certificate. The server infers authentication, signing, and encryption purposes from supported Key Usage and Extended Key Usage metadata. Select fallback purposes only when no supported purposes can be inferred. The inventory displays subject, issuer, serial number, public-key algorithm, validity dates, SHA-256 certificate fingerprint, and upload time. The same certificate cannot be uploaded twice, even in a different encoding.

  • Accepts exactly one public X.509 certificate per upload, in PEM (CERTIFICATE) or binary DER format, at most 32 KiB. Filenames and extensions are not used for validation or storage paths.
  • Rejects private keys, mixed certificate/private-key files, certificate bundles, malformed files, and other key formats. CSRs, PKCS#7, and PKCS#12 are not supported.
  • Uploads require an authenticated admin session and the same-origin checks used by other mutations. The whole multipart request is limited to 64 KiB.
  • Certificates and purpose labels persist in private DATA_DIR/certificates.json, using the existing atomic writes and 0600 permissions. Inventory is limited to 100 certificates and 3 MiB of serialized data, below the storage read limit. The parsed public metadata and PEM certificate are published on /; the JSON storage file is not served.
  • Inferred purpose labels summarize supported certificate usage metadata; fallback labels describe intended use. Neither modifies certificate constraints or replaces validation by a relying party. Uploading checks certificate syntax, not chain trust, revocation, current validity, or possession of the private key. Expired and self-signed certificates can be inventoried; check their displayed validity dates before use.
  • Labels and purposes can be edited, and certificates can be deleted. Public downloads are available under /entries; certificate-chain management is not implemented.

Use the separate Public keys form above for the other supported formats. The X.509 form intentionally accepts only X.509 public certificates.

Editing and deleting inventory entries

On /admin, each public-key and X.509 certificate entry has Edit label and purposes controls. Expand them, change the label and purpose checkboxes, and choose Save changes. The current values are prefilled. Labels retain the upload rules (1–100 characters after trimming); at least one distinct purpose is required, and each key format retains its allowed purposes.

Key/certificate bytes, format, fingerprint, and original upload time are immutable. To replace material, deliberately delete the old entry and upload the replacement; keep a copy of the public export first if you may need it again. WireGuard metadata edits do not require re-uploading or re-confirming the unchanged public value.

Choose Delete entry… to open a confirmation page showing the label, format, and fingerprint. Nothing is removed by opening that page or cancelling. Deletion requires checking the confirmation box and submitting Permanently delete entry. This removes only that inventory record; it does not revoke credentials, remove them from relying systems, delete authenticator passkeys or private keys, or modify the other inventory.

Both operations require an authenticated admin session and the existing exact-origin protections. Writes remain atomic and permission-restricted. Stable URL identifiers are derived from immutable format/fingerprint values, so no data migration is needed and removing one entry cannot shift another entry's identity. Forms include a revision check: if another tab edits, deletes, or reimports an entry, stale submissions are rejected rather than overwriting newer metadata or deleting the reimported entry. Review the refreshed inventory before trying again.

File storage

By default, private runtime data lives in ./data/:

data/
  .lock             # OS-held exclusive process lock
  admin.json        # stable admin ID, RP ID, credential public keys and metadata;
                    # hashed enrollment token only until first enrollment
  certificates.json # uploaded public X.509 certificates (DER), labels and purposes
  keys.json         # typed SSH/OpenPGP/age/minisign/WireGuard public inventory
  sessions/         # one JSON file per session, named by SHA-256(cookie token)
  • Directories use mode 0700; data files use 0600.
  • Writes use private temporary files, fsync, and atomic rename; HTTP storage access is serialized.
  • The local OS file lock permits only one database-owning process per data directory; setup commands can communicate with a running server through its private Unix socket. This implementation targets macOS and Linux, not Windows or shared/network filesystems.
  • Login sessions expire after 12 hours and survive a restart. Expired session files are pruned on startup and session creation, and on access.
  • WebAuthn challenges are single-use, bound to an HttpOnly ceremony cookie, kept in memory, and expire after 5 minutes. Restarting invalidates in-flight ceremonies.
  • Session tokens are random and stored only as hashes on disk. Cookies are HttpOnly, SameSite=Strict, and Secure when ORIGIN uses HTTPS. Logout deletes the session file.
  • Every POST requires an exact matching Origin. JSON initiation endpoints are rate-limited globally (30/minute), and pending ceremonies are bounded.
  • WebAuthn requires user verification and discoverable credentials. Login validates cryptographic signatures, challenge, RP ID, origin, and authenticator flags; updated counters and flags are persisted.
  • data/ is ignored by Git and never served directly over HTTP. Only the parsed public inventory is published; admin identity and session files stay private. If using a custom data path inside the repository, add that path to your ignore rules too. Keep data outside any public web root.

Back up the private data directory securely, with the server stopped for a consistent snapshot. Session files grant access if paired with their cookie tokens; omit sessions/ when restoring backups to invalidate old sessions. The host account and local filesystem are trusted; this is not protection against an attacker who controls the host. Data is permission-restricted, not encrypted at rest.

Configuration / deployment

The server and setup automatically load an optional .env file from the current working directory. Existing environment variables take precedence, including variables explicitly set to an empty value. A missing file is ignored; unreadable or malformed files stop startup. Changes require a restart. --generate-provider-key does not load .env.

Copy the tracked example to .env in the directory where you run ./bin/pubkeys, then restrict its permissions before editing it:

cp .env.example .env
chmod 600 .env

For example:

ADDR=127.0.0.1:3000
ORIGIN=http://localhost:3000
DATA_DIR=data
# Optional: generate with ./bin/pubkeys --generate-provider-key and paste its output:
# PROVIDER_ENCRYPTION_KEY=...

Quoted values and comments are supported. Startup and setup reject .env files with any group or other permission bits set; use chmod 600 .env (owner-only 0400 is also accepted). The file must be a regular file. It is ignored by Git and may contain provider encryption keys. Preserve the original encryption key for existing connections. Docker deployments can continue using docker run --env-file .env; values passed into the container take precedence over any mounted .env file.

Variable Default Purpose
ADDR 127.0.0.1:8080 HTTP listen address
ORIGIN http://localhost:8080 Exact browser-facing origin (no trailing slash or path); hostname becomes RP ID
DATA_DIR data Private local storage directory

For another local port, use the same settings for both setup and server:

ORIGIN=http://localhost:3000 ADDR=127.0.0.1:3000 ./bin/pubkeys setup
ORIGIN=http://localhost:3000 ADDR=127.0.0.1:3000 ./bin/pubkeys

For deployment, configure a stable HTTPS origin, for example ORIGIN=https://admin.example.com, and terminate TLS at a trusted reverse proxy in front of the loopback listener. Plain HTTP is accepted only for localhost. The app does not manage TLS certificates and does not infer its origin from forwarded headers. Do not expose the backend listener directly. Use separate data directories for local development and production: credentials are tied to the RP hostname. Changing the RP hostname requires a planned re-enrollment, not editing the stored RP ID.

HTMX 2.0.4 is vendored in internal/ui/static/htmx.min.js, embedded into the binary, and served locally. The app uses a same-origin Content Security Policy and no CDN scripts or inline script execution. Its license is in internal/ui/static/HTMX-LICENSE.txt.

Development

make run          # generate, build, and start; environment variables are inherited
make generate     # regenerate Go templates and compiled CSS without building
make watch-css    # optional CSS watcher in another terminal
make fmt          # format Go and templ source
make help         # list build targets

Edit internal/ui/views.templ and internal/ui/styles.css, never their generated outputs. Keep both internal/ui/views_templ.go and internal/ui/static/style.css in Git so go test ./... and go build ./cmd/pubkeys also work directly from a checkout; use make build to ensure generated output is fresh. The templ generator and runtime are pinned to v0.3.1118, and frontend versions are pinned in package.json and package-lock.json.

The CSS watcher writes compiled CSS but does not update an already-running binary. Rebuild/restart the server after template, JavaScript, or CSS changes. make clean removes only bin/; it does not remove runtime data or checked-in generated assets.

The existing HTTP/security tests use a software ES256 authenticator to exercise the real WebAuthn library. Authentication and storage stay together in internal/server to keep their private interfaces small; UI rendering and asset ownership live in internal/ui.

An opt-in HKP interoperability test uses installed gpg, gpgconf, and dirmngr binaries against a local test server. It checks search, retrieval, and revocation refresh using a temporary GnuPG home, without modifying your normal keyring:

PUBKEYS_TEST_GPG=1 go test ./internal/server -run '^TestHKPGnuPG$' -count=1

Tests do not replace a real-device browser smoke test. Verify first enrollment, logout/login, cancellation/retry, and backup-passkey enrollment on your intended browser/device before deployment. This is an authentication foundation, not a completed public-key management application or an independently audited security product.

License

This project's original code is licensed under the MIT License. Third-party dependencies retain their own licenses; the vendored HTMX license is preserved in internal/ui/static/HTMX-LICENSE.txt. The Docker image includes both notices in /usr/share/licenses/pubkeys/.