Dashlane CLI
Access your Dashlane vault from the command line. Read-only access to passwords, secure notes, secrets and OTP codes.
Installation
CODEBLOCK0
Authentication
First sync to trigger authentication:
CODEBLOCK1
Steps:
- 1. Enter your Dashlane email
- ⚠️ IMPORTANT: Open the URL shown in your browser (device registration)
- Enter the code received by email
- Enter your Master Password
Check current account:
CODEBLOCK2
Get a Password
CODEBLOCK3
Get a Secure Note
CODEBLOCK4
Get a Secret
Dashlane secrets are a dedicated content type for sensitive data.
CODEBLOCK5
Other Commands
CODEBLOCK6
Configuration
CODEBLOCK7
Persistence by Platform
macOS
Master password is stored in the
Keychain by default. Survives reboots.
CODEBLOCK8
Linux (server/headless)
No native keychain. Options:
- 1. Environment variable (less secure, but simple):
export DASHLANE_MASTER_PASSWORD="..."
- 2. Local encrypted file:
save-master-password true stores in INLINECODE1 - External secret manager (Vault, AWS Secrets, etc.) to inject the variable
Docker / CI
Use the
DASHLANE_MASTER_PASSWORD environment variable passed to the container.
CODEBLOCK10
SSO / Passwordless
Not supported by dcli yet — requires a classic master password.
Advanced: Inject Secrets
CODEBLOCK11
Examples
Get OTP for 2FA
CODEBLOCK12
SSH Keys from Vault
Store private key in a secure note, then:
CODEBLOCK13
Scripting
CODEBLOCK14
Troubleshooting
- - Locked? Run
dcli sync to unlock - SSO users: Need Chrome installed + visual interface
- Password-less: Not supported yet
- Debug mode: INLINECODE4
Docs: https://cli.dashlane.com
技能名称: dashlane
详细描述:
Dashlane CLI
从命令行访问你的 Dashlane 保管库。对密码、安全笔记、机密信息和 OTP 验证码提供只读访问。
安装
bash
brew install dashlane/tap/dashlane-cli
身份验证
首次同步以触发身份验证:
bash
dcli sync
步骤:
- 1. 输入你的 Dashlane 邮箱
- ⚠️ 重要提示:在浏览器中打开显示的 URL(设备注册)
- 输入通过邮箱收到的验证码
- 输入你的主密码
检查当前账户:
bash
dcli accounts whoami
获取密码
bash
按 URL 或标题搜索(默认将密码复制到剪贴板)
dcli p mywebsite
dcli password mywebsite
获取特定字段
dcli p mywebsite -f login # 用户名/登录名
dcli p mywebsite -f email # 邮箱
dcli p mywebsite -f otp # TOTP 双因素验证码
dcli p mywebsite -f password # 密码(默认)
输出格式
dcli p mywebsite -o clipboard # 复制到剪贴板(默认)
dcli p mywebsite -o console # 打印到标准输出
dcli p mywebsite -o json # 完整 JSON 输出(所有匹配项)
按特定字段搜索
dcli p url=example.com
dcli p title=MyBank
dcli p id=xxxxxx # 按保管库 ID
dcli p url=site1 title=site2 # 多条件筛选(或关系)
获取安全笔记
bash
dcli note [筛选条件]
dcli n [筛选条件] # 简写
按标题筛选(默认)
dcli n my-note
dcli n title=api-keys
输出格式:text(默认),json
dcli n my-note -o json
获取机密信息
Dashlane 机密信息是专用于敏感数据的内容类型。
bash
dcli secret [筛选条件]
按标题筛选(默认)
dcli secret api_keys
dcli secret title=api_keys -o json
其他命令
bash
手动同步保管库(默认每小时自动同步一次)
dcli sync
锁定保管库(需要主密码才能解锁)
dcli lock
完全注销
dcli logout
备份保管库到当前目录
dcli backup
dcli backup --directory /path/to/backup
配置
bash
在操作系统钥匙串中保存主密码(默认:true)
dcli configure save-master-password true
禁用自动同步
dcli configure disable-auto-sync true
启用生物识别解锁(仅 macOS)
dcli configure user-presence --method biometrics
禁用用户存在检查
dcli configure user-presence --method none
各平台的持久化方案
macOS
默认情况下,主密码存储在
钥匙串中。重启后依然保留。
bash
dcli configure save-master-password true
Linux(服务器/无头模式)
没有原生钥匙串。可选方案:
- 1. 环境变量(安全性较低,但简单):
bash
export DASHLANE
MASTERPASSWORD=...
- 2. 本地加密文件:save-master-password true 存储在 ~/.local/share/dcli/
- 外部密钥管理器(Vault、AWS Secrets 等)用于注入变量
Docker / CI
使用传递给容器的 DASHLANE
MASTERPASSWORD 环境变量。
bash
docker run -e DASHLANE
MASTERPASSWORD=... myimage
SSO / 无密码
dcli 尚不支持——需要传统的主密码。
高级:注入机密信息
bash
将机密信息注入环境变量
dcli exec -- mycommand
注入到模板文件中
dcli inject < template.txt > output.txt
按路径读取机密信息
dcli read dl://vault/secret-id
示例
获取双因素验证的 OTP
bash
dcli p github -f otp
返回:123456(剩余 25 秒)
从保管库获取 SSH 密钥
将私钥存储在安全笔记中,然后:
bash
dcli n SSH_KEY | ssh-add -
脚本编写
bash
为脚本获取密码
PASSWORD=$(dcli p myservice -o console)
获取 JSON 并使用 jq 解析
dcli p myservice -o json | jq -r .[0].password
故障排除
- - 已锁定? 运行 dcli sync 解锁
- SSO 用户: 需要安装 Chrome 浏览器 + 可视化界面
- 无密码用户: 尚不支持
- 调试模式: dcli --debug
文档:https://cli.dashlane.com