How-To Series · 9: Locking It Down

Bitwarden Secrets

Pull your API keys from Bitwarden Secrets Manager every time Hermes starts, instead of keeping them in plain text in ~/.hermes/.env.

After this videoYou can move your provider keys into Bitwarden Secrets Manager, connect Hermes with one machine-account token, and rotate a key in one place.

One bootstrap secret, a Bitwarden machine-account access token, replaces every per-provider key. Hermes stores it in ~/.hermes/.env as BWS_ACCESS_TOKEN. Each time hermes, the gateway or a cron job starts, after .env loads, Hermes runs bws secret list for your project and sets the returned keys in the environment. By default Bitwarden overrides values already there, so a key you rotate once in the web app reaches every Hermes process on its next start; set override_existing: false if you want .env to win. In the Bitwarden web app, where your normal 2FA applies, you create a project, add secrets whose names become the environment variable names (OPENROUTER_API_KEY), create a machine account with Read access, and copy its access token, which Bitwarden cannot show again. hermes secrets bitwarden setup installs bws if needed, stores the token, asks for your region (US Cloud, EU Cloud or self-hosted), picks the project, test-fetches and turns it on. A fetch result is reused for cache_ttl_seconds (300 by default). An optional encrypted cache of the last good fetch can be used for up to max_stale_seconds, only after network or timeout failures, never after authentication failures. Bitwarden never blocks startup: on failure Hermes prints a one-line warning naming the fix and keeps the keys already in .env.

About these resources. Every command and setting in this video comes from the Bitwarden Secrets Manager doc. For website logins through the bw CLI rather than API keys, see the Passwords & Logins episode below.

New words here · Plain English

one sentence each · full glossary
Bitwarden Secrets ManagerBitwarden's service for storing API keys and other machine secrets. Hermes can pull your provider keys from it every time it starts, instead of keeping them in plain text in .env.
Machine accountA non-human Bitwarden account with read access to one project's secrets. It has no 2FA prompt because no person logs in; its access token is the credential.
Access token (Bitwarden)The one bootstrap secret Hermes keeps in .env as BWS_ACCESS_TOKEN. Anyone holding it can read every secret the machine account can see, so treat it like an API key.
Override existingThe Bitwarden setting that decides who wins. On by default, so a key rotated in Bitwarden replaces the .env value; turn it off to let .env win locally.

Sources · What this video distills

1 docs page · every command below traces to it
Primary guide
Bitwarden Secrets Manager
Read ↗

Commands shown · Copy and paste

each shows the source doc it came from
Wizard: install bws, store the token, pick region and project, test-fetch, enablefrom source ↗
hermes secrets bitwarden setup
Show config, binary version and token presencefrom source ↗
hermes secrets bitwarden status
Rotate an expired or revoked token (validated before it is stored)from source ↗
hermes secrets bitwarden token
Dry run: pull secrets now and show what would be appliedfrom source ↗
hermes secrets bitwarden sync
Turn it off; the token and project id stay in placefrom source ↗
hermes secrets bitwarden disable

Going deeper · Related Hermes docs

further reading · not sources of facts shown above

Next in the series · Episodes that build on this