~/.mibyan/.env. One bootstrap secret (a machine-account access token) replaces N per-provider keys, and rotating a credential becomes a single change in the Bitwarden web app.
How it works
- You create a machine account in Bitwarden Secrets Manager, give it read access to a project, and generate an access token.
- Mibyan stores that single token in
~/.mibyan/.envasBWS_ACCESS_TOKEN. - Every time
mibyan(or the gateway, or a cron job) starts, after~/.mibyan/.envhas loaded, Mibyan callsbws secret list <project_id>and sets the returned keys intoos.environ. - By default Mibyan overrides values already in your environment, so Bitwarden is the source of truth — rotate a key once in the web app and every Mibyan process picks it up on next start. Flip
override_existing: falsein config if you want.envto win instead.
bws executable on PATH before checking PM selection.
If neither exists, first use requests the pinned package from
PM, subject to the lazy-install policy.
Why machine accounts (and why no 2FA prompt)
Bitwarden Secrets Manager is designed for non-interactive workloads: machine accounts can’t be 2FA-gated because there’s no human in the loop. The access token is the credential. Anyone with it can read every secret the machine account has access to, so treat it like a high-value bearer token — store it in.env (not config.yaml), and revoke + regenerate from the Bitwarden web app if it ever leaks.
You set up the machine account in the web app, where your normal 2FA applies. After that the token is autonomous.
Setup
1. Create a machine account and access token
In the Bitwarden web app (or vault.bitwarden.eu for EU accounts):- Switch to Secrets Manager from the product switcher.
- Create or pick a Project (e.g. “Mibyan keys”).
- Add your provider keys as secrets. The secret Name becomes the environment variable name — use
OPENROUTER_API_KEY,ANTHROPIC_API_KEY, etc. - Machine accounts → New machine account → My Mibyan machine → Projects tab → grant Read access to your project.
- Access tokens tab → Create access token → Never expires (or pick a date) → copy the token (starts with
0.). Bitwarden cannot retrieve it again — keep the copy.
2. Run the wizard
- If
bwsis absent, request its pinned package from PM. - Prompt you for the access token (input is hidden). Stored in
~/.mibyan/.envasBWS_ACCESS_TOKEN. - Ask which Bitwarden region your machine account belongs to — US Cloud, EU Cloud, or self-hosted / custom URL. Stored in
config.yamlassecrets.bitwarden.server_urland passed tobwsasBWS_SERVER_URL. - List the projects the machine account can see; pick one. Stored in
config.yamlassecrets.bitwarden.project_id. - Test-fetch the project’s secrets and show you which env vars will resolve.
- Flip
secrets.bitwarden.enabled: true.
3. Confirm
mibyan invocation pulls fresh secrets at startup. You’ll see a one-line summary in stderr the first time secrets are applied in a process.
CLI
Rotating an expired or revoked token
When the machine-account token expires, gets revoked, or the account is deleted, startup shows:.env untouched. On success it stores the token, clears the fetch caches, and warns if the configured project is not visible to the new machine account.
Configuration
Defaults in~/.mibyan/config.yaml:
Failure modes
Bitwarden never blocks Mibyan startup. If anything goes wrong, you’ll see a one-line warning in stderr and Mibyan continues with whatever credentials.env already had:
Startup warnings now include a
→ remediation line telling you exactly which command fixes the failure.
Security notes
- The bootstrap token (
BWS_ACCESS_TOKEN) is itself sensitive — anyone with it can read every secret the machine account has access to. Treat it the same as any other API key. - Mibyan will refuse to let Bitwarden overwrite the bootstrap token itself, even with
override_existing: true. If you storeBWS_ACCESS_TOKENas a secret inside the project, it’s silently skipped during apply. - PM checks the managed archive against its SHA-256 hash in
pm/lock.json. A mismatch aborts installation. - The same lock declares the version. First use does not resolve a “latest” release. External binaries remain outside these PM checks.
When NOT to use this
- Single-machine personal setups where
~/.mibyan/.envis fine. You’re trading one credential for another and adding a network dependency at startup. - Air-gapped environments that can’t reach
api.bitwarden.com. - CI/CD where the existing secrets-injection mechanism (GitHub Actions secrets, Vault, etc.) is already set up — pick one path, not two.

