// DevOps
Bitwarden CLI: password management from the terminal and CI/CD automation
Published on 2026-06-02
In the previous article we deployed our own Vaultwarden server. Today — how to work with it from the console and integrate it into automation.
Bitwarden CLI (the bw utility) — the official open-source command-line tool. It allows you to find credentials right in the terminal and securely pass secrets into scripts and pipelines (GitHub Actions, GitLab CI, etc.). Completely free and compatible with self-hosted Vaultwarden.
1. Installation
# Via NPM (any OS)
npm install -g @bitwarden/cli
# macOS
brew install bitwarden-cli
# Linux (Ubuntu/Debian)
sudo snap install bwCheck:
bw --version2. Connecting to your server
By default the CLI points to the Bitwarden cloud. Switch to Vaultwarden:
bw config server https://vault.yourdomain.com3. Authentication: two scenarios
Scenario A: Interactive login (personal PC)
bw loginScenario B: Non-interactive login (CI/CD)
Generate API keys in the web interface: Account Settings → Security → API Keys, then:
export BW_CLIENTID="user.xxxxx-xxxx-xxxx"
export BW_CLIENTSECRET="xxxxxxxxxxxxxx"
bw login --apikey4. Unlocking the vault and BW_SESSION
login only authenticates to the server — the data is still encrypted. To decrypt it:
bw unlockThe system will return a session token:
export BW_SESSION="AI39...=="Copy and execute that line. While the $BW_SESSION variable is set, the utility decrypts passwords locally in memory without asking for the master password for every command.
In scripts — in one line:
export BW_SESSION=$(bw unlock --passwordenv BW_PASSWORD --raw)5. Basic commands
| Task | Command |
|---|---|
| Search item | bw list items --search "github" |
| Get password | bw get password "github" |
| Get username | bw get username "github" |
| TOTP code (2FA) | bw get totp "github" |
| Entire item | bw get item <ID> |
Copy password to clipboard (Linux):
bw get password github | xclip -selection clipboard6. CI/CD script template
#!/usr/bin/env bash
set -e
# 1. Server address
bw config server https://vault.yourdomain.com
# 2. Login with API keys (BW_CLIENTID and BW_CLIENTSECRET — in CI environment variables)
bw login --apikey
# 3. Unlock
export BW_SESSION=$(bw unlock --passwordenv BW_PASSWORD --raw)
# 4. Get secret by item ID
# Find ID beforehand: bw list items --search "my-db"
DB_PASS=$(bw get item "8a562df1-443b-4892-baee-b123456789ab" | jq -r '.login.password')
echo "Starting deployment..."
# ./deploy.sh --pass=$DB_PASS
# 5. End the session
bw logoutSecurity guidelines
- Do not store
BW_SESSIONon disk — only in the memory of the current session or CI/CD process. - Always call
bw logoutat the end of scripts — it clears local encrypted caches. - Mask output in CI/CD — use secret-masking mechanisms (
::add-mask::in GitHub Actions) so passwords don’t appear in public logs.
Conclusion
Bitwarden CLI turns Vaultwarden into a full-fledged secrets store for infrastructure. Hardcoding passwords in config files and Git repositories — it’s over.
If Vaultwarden isn’t deployed yet — start with the previous article: Vaultwarden in 30 minutes.
// Reviews
Related reviews
I came with an expensive request to configure a VPS server, but during the consultation Mikhail suggested a much simpler, more affordable solution. In the end I saved time and money. Mikhail — a true expert who works for the client's result, not for the fee. I recommend him!
I came with an expensive request to configure a VPS server, but during the consultation Mikhail suggested a much simpler and more cost-effective solution. In the end I saved budget and time. Mikhail — a true expert who …
VPS setup, server setup
2026-05-12 · ★ 5/5
Excellent work! Set up the server very quickly, installed the control panel, and configured the IP. Definitely recommend!
Excellent work! Very quickly set up the server, installed the panel, configured the IP I can definitely recommend it!
Everything was excellent; helped promptly and professionally. Thank you — I recommend them to the community.
Everything's great, helped promptly and professionally, thank you, I recommend it to the community
VPS setup, server setup
2026-04-16 · ★ 5/5
There were several issues concerning both the technical side and overall understanding. Mikhail responded quickly, resolved the technical problems, and helped me understand them — many thanks. I'm satisfied with the result.
There were several issues concerning both the technical side and overall understanding. Mikhail responded quickly to the request, helped sort things out and resolved the technical problems and helped clarify …
VPS setup, server setup
2026-02-18 · ★ 5/5
Everything was done quickly and efficiently. I recommend.
Everything was done quickly and efficiently. I recommend.
VPS setup, server setup
2026-01-17 · ★ 5/5
Everything went well; the contractor responded quickly to questions and helped resolve the issue. Thanks!
Everything went well, the contractor responded quickly to questions and helped resolve the issue. Thank you!
VPS setup, server setup
2025-12-16 · ★ 5/5
// Contact
Need help?
Get in touch with me and I'll help solve the problem
Message on TelegramОтвечаю в течение рабочего дня (03:00–13:00 GMT)
Или оставьте заявку здесь:
// Related