1password
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese1Password CLI
1Password CLI
Use the 1Password CLI () to fetch and manage secrets without exposing them in plain text.
op使用1Password CLI()获取和管理密钥,无需以明文形式暴露它们。
opFetching Secrets
获取密钥
Ask the user for their 1Password secret reference (right-click field in 1Password → "Copy Secret Reference"):
bash
undefined请用户提供他们的1Password密钥引用(在1Password中右键点击字段→“复制密钥引用”):
bash
undefinedRead a secret value
读取密钥值
op read "op://Vault/Item/field"
op read "op://Vault/Item/field"
Use in a command (secret never shown in shell history)
在命令中使用(密钥不会出现在Shell历史记录中)
some-cli --token "$(op read 'op://Vault/Item/api-key')"
some-cli --token "$(op read 'op://Vault/Item/api-key')"
Use as environment variable
用作环境变量
export API_KEY="$(op read 'op://Vault/Item/api-key')"
undefinedexport API_KEY="$(op read 'op://Vault/Item/api-key')"
undefinedCommon Patterns
常见使用模式
bash
undefinedbash
undefinedCLI auth
CLI认证
toggl auth "$(op read 'op://Employee/Toggl/api key')"
gh auth login --with-token < <(op read 'op://Personal/GitHub/token')
toggl auth "$(op read 'op://Employee/Toggl/api key')"
gh auth login --with-token < <(op read 'op://Personal/GitHub/token')
Docker login
Docker登录
docker login -u $(op read op://Vault/Docker/username) -p $(op read op://Vault/Docker/password)
undefineddocker login -u $(op read op://Vault/Docker/username) -p $(op read op://Vault/Docker/password)
undefinedReference Format
引用格式
op://vault-name/item-name/field-name
op://vault-name/item-name/section-name/field-nameSpecial fields:
bash
op read "op://Vault/Item/one-time password?attribute=otp" # TOTP
op read "op://Vault/Item/private key?ssh-format=openssh" # SSH keyop://vault-name/item-name/field-name
op://vault-name/item-name/section-name/field-name特殊字段:
bash
op read "op://Vault/Item/one-time password?attribute=otp" # TOTP一次性密码
op read "op://Vault/Item/private key?ssh-format=openssh" # SSH密钥Creating Items
创建条目
Field Type Syntax
字段类型语法
bash
"Field Name[text]=value" # Plain text (visible)
"Field Name[concealed]=value" # Password/secret (hidden)
"Field Name[url]=https://..." # Clickable URL
"Field Name[delete]" # Remove a fieldDefault (no suffix) = concealed. Always be explicit about field types.
bash
"Field Name[text]=value" # 纯文本(可见)
"Field Name[concealed]=value" # 密码/密钥(隐藏)
"Field Name[url]=https://..." # 可点击URL
"Field Name[delete]" # 删除字段默认(无后缀)= 隐藏。请始终明确指定字段类型。
Principles
原则
- Only conceal actual secrets — passwords, API keys, tokens. URLs, usernames, client IDs, hostnames, ports, and other non-sensitive identifiers must use or
[text]. If someone would read it aloud in a meeting, it's not a secret.[url] - Use clear, descriptive field names — Match the source terminology
- Include context — Add account info, notes, and details
- Clean up template cruft — Remove or set default fields from templates
- 仅对实际密钥设置隐藏 — 密码、API密钥、令牌。URL、用户名、客户端ID、主机名、端口及其他非敏感标识符必须使用或
[text]。如果某信息可以在会议中大声读出,那它就不是密钥。[url] - 使用清晰、描述性的字段名称 — 与服务文档中的术语保持一致
- 包含上下文信息 — 添加账户信息、备注和详细说明
- 清理模板冗余字段 — 删除或设置模板中的默认字段
OAuth API Credential
OAuth API凭据
bash
op item create --category="API Credential" --title="Service Name - App Name" --vault="VaultName" \
"Client ID[text]=ABC123" \
"Client Secret[concealed]=secret-value-here" \
"Account[text]=user@example.com" \
"Redirect URL[text]=http://localhost:8080" \
"Authorization URL[text]=https://service.com/oauth2/authorize" \
"Token Request URL[text]=https://api.service.com/oauth2/token" \
"Developer Portal[url]=https://developer.service.com" \
"notesPlain=Context about this credential and any gotchas."bash
op item create --category="API Credential" --title="Service Name - App Name" --vault="VaultName" \
"Client ID[text]=ABC123" \
"Client Secret[concealed]=secret-value-here" \
"Account[text]=user@example.com" \
"Redirect URL[text]=http://localhost:8080" \
"Authorization URL[text]=https://service.com/oauth2/authorize" \
"Token Request URL[text]=https://api.service.com/oauth2/token" \
"Developer Portal[url]=https://developer.service.com" \
"notesPlain=Context about this credential and any gotchas."Simple API Key
简单API密钥
bash
op item create --category="API Credential" --title="Service Name API" --vault="VaultName" \
"API Key[concealed]=sk-xxxxxxxxxxxx" \
"Account[text]=user@example.com" \
"Documentation[url]=https://docs.service.com/api" \
"notesPlain=Used for X purpose. Rate limit: 1000/day."bash
op item create --category="API Credential" --title="Service Name API" --vault="VaultName" \
"API Key[concealed]=sk-xxxxxxxxxxxx" \
"Account[text]=user@example.com" \
"Documentation[url]=https://docs.service.com/api" \
"notesPlain=Used for X purpose. Rate limit: 1000/day."Database Credential
数据库凭据
bash
op item create --category="Database" --title="Production DB - ServiceName" --vault="VaultName" \
"type[text]=postgresql" \
"server[text]=db.example.com" \
"port[text]=5432" \
"database[text]=myapp_production" \
"username[text]=app_user" \
"password[concealed]=secret-password" \
"notesPlain=Read replica. Primary is on port 5433."bash
op item create --category="Database" --title="Production DB - ServiceName" --vault="VaultName" \
"type[text]=postgresql" \
"server[text]=db.example.com" \
"port[text]=5432" \
"database[text]=myapp_production" \
"username[text]=app_user" \
"password[concealed]=secret-password" \
"notesPlain=Read replica. Primary is on port 5433."Editing Existing Items
编辑现有条目
When adding fields to existing items with , the same type rules apply — always specify the field type explicitly:
op item editbash
undefined使用为现有条目添加字段时,同样适用上述类型规则——请始终明确指定字段类型:
op item editbash
undefinedWRONG — defaults to concealed, hides the URL and username
错误示例 — 默认设置为隐藏,会隐藏URL和用户名
op item edit "My Item" "Section.URL=https://example.com" "Section.username=admin"
op item edit "My Item" "Section.URL=https://example.com" "Section.username=admin"
RIGHT — only the password is concealed
正确示例 — 仅对密码设置隐藏
op item edit "My Item" "Section.URL[url]=https://example.com" "Section.username[text]=admin" "Section.password[concealed]=secret"
undefinedop item edit "My Item" "Section.URL[url]=https://example.com" "Section.username[text]=admin" "Section.password[concealed]=secret"
undefinedHandling Template Fields
处理模板字段
Some categories add default fields like and set to epoch 0.
valid fromexpiresbash
undefined部分分类会添加默认字段,比如设置为纪元0的和。
valid fromexpiresbash
undefinedDelete if not applicable
若不适用则删除
op item edit "Item Name" --vault="VaultName" "valid from[delete]" "expires[delete]"
op item edit "Item Name" --vault="VaultName" "valid from[delete]" "expires[delete]"
Set if applicable
若适用则设置
op item edit "Item Name" --vault="VaultName" "valid from=2026-01-27" "expires=2027-01-27"
undefinedop item edit "Item Name" --vault="VaultName" "valid from=2026-01-27" "expires=2027-01-27"
undefinedField Naming
字段命名规范
| Bad | Good |
|---|---|
| |
| |
| |
Match the terminology from the service's docs.
| 不佳命名 | 良好命名 |
|---|---|
| |
| |
| |
请与服务文档中的术语保持一致。
Prerequisites
前提条件
- 1Password app installed with CLI integration enabled
- User signed in (if not authenticated)
op signin - Check vaults:
op vault list - Docs: https://developer.1password.com/docs/cli
- 已安装1Password应用并启用CLI集成
- 用户已登录(若未认证请使用)
op signin - 查看可用保险箱:
op vault list - 文档:https://developer.1password.com/docs/cli