Linux command
1password 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Sign in
op signin
List all items
op item list --vault [vault_name]
Get details
op item get "[item_name]"
Get specific fields
op item get "[item_name]" --fields label=username,label=password
Read a secret
op read "op://[vault]/[item]/[field]"
Run a command
op run --env-file [.env] -- [command]
Create a new item
op item create --category login --title "[title]" --vault [vault_name]
List all vaults
op vault list
说明
op is the official command-line interface for 1Password, a password manager and secrets management platform. It enables secure access to passwords, credentials, and sensitive data directly from the terminal. The CLI follows a noun-verb command structure where the first argument is typically a resource type (item, vault, user) followed by an action (get, list, create). It supports both interactive and scripted workflows, making it suitable for development automation and CI/CD pipelines. Key capabilities include retrieving credentials using secret references in the format op://vault/item/field, injecting secrets into environment variables for running processes, and managing vault contents programmatically. The tool uses daemon-based caching on Unix systems to improve performance and reduce API calls. Items can be referenced by name or by their 26-character alphanumeric ID, with IDs being more stable and efficient for automation. Output can be formatted as JSON for integration with tools like jq.
参数
- account
- Manage locally configured 1Password accounts
- item
- Perform CRUD operations on vault items (get, list, create, edit, delete)
- vault
- Manage vaults and their permissions
- document
- Manage document-type items (get, list, create, edit, delete)
- read
- Resolve and retrieve secret references
- run
- Pass secrets as environment variables to a subprocess
- inject
- Insert secrets into configuration files or templates
- signin
- Authenticate to a 1Password account
- signout
- End the current session
- whoami
- Display information about the signed-in account
- completion
- Generate shell completion scripts
- --format _json_
- Output results in JSON format for parsing with tools like jq
- --fields _label=field_
- Specify particular fields to retrieve from an item
- --vault _name_
- Target a specific vault for the operation
- --cache=false
- Disable daemon caching (useful in restricted environments)
FAQ
What is the 1password command used for?
op is the official command-line interface for 1Password, a password manager and secrets management platform. It enables secure access to passwords, credentials, and sensitive data directly from the terminal. The CLI follows a noun-verb command structure where the first argument is typically a resource type (item, vault, user) followed by an action (get, list, create). It supports both interactive and scripted workflows, making it suitable for development automation and CI/CD pipelines. Key capabilities include retrieving credentials using secret references in the format op://vault/item/field, injecting secrets into environment variables for running processes, and managing vault contents programmatically. The tool uses daemon-based caching on Unix systems to improve performance and reduce API calls. Items can be referenced by name or by their 26-character alphanumeric ID, with IDs being more stable and efficient for automation. Output can be formatted as JSON for integration with tools like jq.
How do I run a basic 1password example?
Run `op signin` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does account do in 1password?
Manage locally configured 1Password accounts