Safeguard
Security Guides•

htpasswd or token auth for a self-hosted Docker registry?

Use htpasswd for a small team over TLS, and token auth when you need central identity and separate rights. How each works and what each costs to run.

Safeguard Security Team
4 min read

Choose htpasswd when a handful of people and pipelines need a shared, simple login over TLS. Choose token authentication when you have many users, a central identity system, or a need for different rights per repository. The registry supports one provider at a time, so the decision matters up front.

What each one is

htpasswd is basic authentication against a local file of bcrypt hashes. The registry reads the file named in auth.htpasswd.path, and clients send a username and password with every request.

Token authentication delegates the decision to a separate auth service. The registry sends unauthenticated clients to that service, which checks identity and issues a signed token. The registry then verifies the token. The configuration needs realm, service, issuer and rootcertbundle.

The registry also has a silly provider, but the docs describe it as development only. It checks that an Authorization header is present, not what it says.

Side by side

Questionhtpasswdtoken
Setup effortMinutesA separate service to build or run
Where identities liveA file on the registry hostYour auth service
Per repository rightsNot expressed in the fileDecided by the auth service
Credential rotationEdit the file for each userHandled by the token service
Works without TLSNo, passwords travel in headersStill needs TLS in practice

The Distribution docs say token auth is more complex to set up, and they point to an authenticating proxy as another route for advanced needs.

How to decide

Ask four questions.

  1. How many humans and pipelines need access? Past a dozen or so, editing a file by hand gets error prone.
  2. Do you need read only roles? Deploy systems often should pull but never push. A flat file cannot express that.
  3. Do you already run central identity? If so, token auth lets the registry follow it, and offboarding someone removes registry access in the same step.
  4. Who will operate the auth service? A token service is one more thing to patch and monitor. If nobody owns it, a simple setup that is well run beats a clever one that is neglected.

If you pick htpasswd

Keep the file out of the image and out of version control. Generate hashes with bcrypt, since the registry accepts nothing else. Give each pipeline its own account so logs and revocation are meaningful. Pair it with TLS, because the docs warn that basic auth sends passwords in HTTP headers.

If you pick token auth

Protect the signing key and the root certificate bundle like any other signing material. Short token lifetimes limit damage from a leak. Make sure the auth service logs every grant, because the registry sees only the token.

Moving later

You can change providers, but every client login changes with it. Plan the cutover: create the new accounts, update CI secrets, then switch. Keep the old path available for a short window and watch the access log for stragglers.

If you want an inventory of what is stored behind either setup, Safeguard's container image scanning and SBOM generation can help, and the free scan is at gold.safeguard.sh/scan.

Quick check

Can I run htpasswd and token auth together?

No. The configuration reference says only one authentication provider can be configured at a time.

Is token auth more secure than htpasswd?

Not automatically. It allows finer rights and central control, but it adds a service and a signing key that you must protect.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.