bitwarden
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBitwarden CLI
Bitwarden CLI
Retrieve secrets when environment variables are missing.
当环境变量缺失时获取机密信息。
CRITICAL: Source .env Before EVERY bw Command
重要提示:在执行每个bw命令前先执行source .env
EVERY command MUST be prefixed with sourcing .env to load :
bwBW_SESSIONbash
undefined所有命令必须以为前缀,以载入环境变量:
bwsource .envBW_SESSIONbash
undefinedStandard prefix for ALL bw commands - copy this pattern exactly:
所有bw命令的标准前缀——完全复制此格式:
source .env 2>/dev/null; bw <command>
Example commands:
```bash
source .env 2>/dev/null; bw status
source .env 2>/dev/null; bw list items --search "telegram"
source .env 2>/dev/null; bw get password "item-name"
source .env 2>/dev/null; bw get notes "item-name"If .env is in a parent directory, search up:
bash
for dir in . .. ../.. ../../..; do [[ -f "$dir/.env" ]] && source "$dir/.env" && break; done; bw statussource .env 2>/dev/null; bw <command>
示例命令:
```bash
source .env 2>/dev/null; bw status
source .env 2>/dev/null; bw list items --search "telegram"
source .env 2>/dev/null; bw get password "item-name"
source .env 2>/dev/null; bw get notes "item-name"如果.env文件位于上级目录,向上搜索:
bash
for dir in . .. ../.. ../../..; do [[ -f "$dir/.env" ]] && source "$dir/.env" && break; done; bw statusSession Management
会话管理
Check status (should show "unlocked" if BW_SESSION is valid):
bash
source .env 2>/dev/null; bw statusIf locked and BW_SESSION not in .env, unlock and save to .env:
bash
echo "BW_SESSION=$(bw unlock --raw)" >> .env检查状态(如果BW_SESSION有效,应显示"unlocked"):
bash
source .env 2>/dev/null; bw status如果密码库已锁定且.env中没有BW_SESSION,解锁并保存到.env:
bash
echo "BW_SESSION=$(bw unlock --raw)" >> .envFinding API Keys
查找API密钥
API keys are often stored in notes - either in a login item's notes field or as a standalone secure note.
-
Search first to find the right item:bash
bw list items --search "openai" -
Check notes - API keys are commonly here:bash
bw get notes "item-name" -
Check custom fields if not in notes:bash
bw get item "item-name" | jq -r '.fields[] | select(.name=="API_KEY") | .value'
API密钥通常存储在备注中——要么在登录项的备注字段,要么作为独立的安全备注。
-
先搜索找到对应的条目:bash
bw list items --search "openai" -
查看备注——API密钥通常在这里:bash
bw get notes "item-name" -
如果备注中没有,检查自定义字段:bash
bw get item "item-name" | jq -r '.fields[] | select(.name=="API_KEY") | .value'
Common Patterns
常见用法示例
| Need | Command |
|---|---|
| Search items | |
| Notes (API keys!) | |
| Password | |
| Username | |
| TOTP | |
| Custom field | |
| 需求 | 命令 |
|---|---|
| 搜索条目 | |
| 查看备注(含API密钥!) | |
| 获取密码 | |
| 获取用户名 | |
| 获取TOTP | |
| 获取自定义字段 | |
CLI Help
CLI帮助
bw [options] [command]
Commands:
login [email] [password] Log into account
unlock [password] Unlock vault, returns session key
lock Lock vault
status Show vault status
list <object> List objects (items, folders, collections)
get <object> <id> Get object (item, username, password, totp, notes)
sync Pull latest vault databw [options] [command]
Commands:
login [email] [password] 登录账户
unlock [password] 解锁密码库,返回会话密钥
lock 锁定密码库
status 显示密码库状态
list <object> 列出对象(条目、文件夹、集合)
get <object> <id> 获取对象(条目、用户名、密码、TOTP、备注)
sync 拉取最新的密码库数据