使用前必须先按 YubiKey-Guide 配好 GnuPG 身份,否则无法加解密;默认剪贴板命令是 xclip,macOS 需设 PURSE_CLIP=pbcopy;密码默认 10 秒后从剪贴板清除,可调 PURSE_TIME。
Purse
drduhMIT活跃维护用 Bash 和 GnuPG 非对称加密管理密码与敏感信息,支持 YubiKey 硬件密钥,适合在命令行里安全存取机密。
Manage secrets with Bash and GnuPG asymmetric encryption (YubiKey)
wget https://github.com/drduh/Purse/blob/master/purse.sh
./purse.sh需要已配置好的 GnuPG 身份和 YubiKey(README 指向 drduh/YubiKey-Guide 配置);README 未说明 CPU 或显存要求。
用 Bash 和 GnuPG 非对称加密管理密码,靠 YubiKey 免输口令
用 Bash 和 GnuPG 非对称加密管理密码与敏感信息,支持 YubiKey 硬件密钥,适合在命令行里安全存取机密。
核心能力
- 基于 GnuPG 公钥加密,无需记忆主口令
- 插入 YubiKey 输 PIN 并触碰即可解密
- 密码带 epoch 时间戳,读取时最新版自动进剪贴板
- 支持按时间戳读取历史版本密码
- 可一键生成备份归档并支持恢复
容易踩的坑
- 3.0Version 3最新正式版2024-07-05 · 2024-07-05 01:19 UTC
The third stable release of Purse password manager with usability improvements, new features and configuration options (detailed in README).
Version 3.0 also addresses the following known issues:
- When creating passwords, having to read the password back after writing it (sometimes only to find it does not meet requirements). The password can now remain on the clipboard for the timeout duration before being saved. If the password is not compatible, just Control-C and generate a new one.
- Password generated with
gpgoften lacked special character diversity and did not meet website requirements. The character set is now a configurabletrsetting to increase password quality.
Changelist
- New option
daily_backup: create daily backup archive on write. Off by default. - New option
pass_copy: keep password on clipboard before write. Helps ensure the password meets requirements before committing. Off by default. - New option
pass_chars: specify characters to use for password. Default is all alphanumeric and some common allowed special characters. - Support for unencrypted comment in safe and index files. Off by default.
- Support for other clipboards (e.g., primary/control-v clipboard with
xclip) - Support for systems without clipboard: passwords will print to screen and clear after timeout.
- Generate username functionality.
- Generate password with
trinstead ofgpgto improve compliance with password requirements. - Reduce default password length 20->14 characters, remove maximum limit.
- Increase filename size 8->10 characters.
- Script exits are trapped for chmod cleanup, now
0000. - Re-order action list so Read is first.
- Error handling and readability improvements.
Full Changelog: https://github.com/drduh/Purse/compare/2.0b1...3.0
- 3.0bVersion 3 Betapre-release2024-03-10 · 2024-03-10 22:28 UTC
查看更新说明
The third release of Purse features new usability features and improvements, specifically addressing:
- When creating passwords, having to read the password back after writing it (sometimes only to find it does not meet requirements). The password can now remain on the clipboard for the timeout duration before being saved. If the password is not compatible, just Control-C and generate a new one.
- Password generated with
gpgoften lacked special character diversity and did not meet website requirements. The character set is now a configurabletrsetting to increase password quality.
Currently in beta testing.
Known Issues:
- Error handling from decryption operation does not always work
- No ability to switch between encrypted/plaintext index
Changelog:
- New option
daily_backup: create daily backup archive on write. Off by default. - New option
pass_copy: keep password on clipboard before write. Helps ensure the password meets requirements before committing. Off by default. - New option
pass_chars: specify characters to use for password. Default is all alphanumeric and some common allowed special characters. - Generate password with
trinstead ofgpgto improve compliance with password requirements. - Reduce default password length 20->12 characters, remove maximum limit.
- Increase filename size 8->10 characters.
- Explicitly unset password variable after write.
- Minor code readability improvements.
- 2.0b1Version 2 Beta 12020-05-25 · 2020-05-25 21:25 UTC
查看更新说明
Minor update to the second release. Currently in beta testing. Compatible on Linux, OpenBSD, macOS.
Known Issues:
- Newer versions of macOS error with
tr: Illegal byte sequence- see issue #4
Changelist:
- Purse now uses a GPG keygroup to encrypt secrets to multiple recipients for improved reliability. The program will prompt for key IDs to define the keygroup; a single key ID can still be used.
- Encrypted index is now optional and off by default, allowing a single touch to encrypt and decrypt secrets instead of two.
- GPG configuration file is now included in Purse backup archives.
- Newer versions of macOS error with
- 2.0bVersion 2 Betapre-release2019-12-02 · 2019-12-02 17:27 UTC
查看更新说明
The second release of purse.sh features several security and reliability improvements, and is an optional upgrade. Currently in beta testing. Compatible on Linux, OpenBSD, macOS.
Known issues:
- Read actions now require two Yubikey touches, if touch to decrypt is enabled - once for the index and twice for the encrypted password file.
Changelist:
- Passwords are now encrypted as individual files, rather than all encrypted as a single flat file.
- Individual password filenames are random, mapped to usernames in an encrypted index file.
- Index and password files are now "immutable" using chmod while purse.sh is not running.
- Read passwords are now copied to clipboard and cleared after a timeout, instead of printed to stdout.
- Use printf instead of echo for improved portability.
- New option: list passwords in the index.
- New option: create tar archive for backup.
- Removed option: delete password; the index is now a permanent ledger.
- Removed option: read all passwords; no use case for having a single command.
- Removed option: suppress generated password output; should be read from safe to verify save.
- 1.0Version 12019-11-26 · 2019-11-26 23:32 UTC
查看更新说明
Original release which has been available for general use and review since June 2018 (forked from pwd.sh dating to 2015). There are no known bugs nor security vulnerabilities identified in this stable version of purse.sh. Compatible on Linux, OpenBSD, macOS.
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Purse is a Bash shell script based on drduh/pwd.sh.
Both programs use GnuPG to manage secrets in encrypted text files. Purse is based on asymmetric (public-key) authentication, while pwd.sh is based on symmetric (passphrase-based) authentication.
Purse eliminates the need for a passphrase: plug in the YubiKey, enter PIN and touch it to access secrets.
[!IMPORTANT] A GnuPG identity is required to use Purse - see drduh/YubiKey-Guide to set one up.
Install
Purse is available for download from Releases, or directly from GitHub:
wget https://github.com/drduh/Purse/blob/master/purse.sh
Use
Run the script interactively using ./purse.sh or symlink to a directory in PATH:
wto create a secretrto access a secretlto list all secretsbto create a backup archivehto print the help text
Options can also be passed on the command line.
Create a 20-character password for userName:
./purse.sh w userName 20
Read password for userName:
./purse.sh r userName
Passwords are stored with an epoch timestamp for revision control. The most recent version is copied to clipboard on read. To list all passwords or read a specific version of a password:
./purse.sh l
./purse.sh r userName@1574723600
Create an archive for backup:
./purse.sh b
Restore an archive from backup:
tar xvf purse*tar
Configure
See config/gpg.conf for recommended GnuPG options.
Several customizable options and features are also available, and can be configured with environment variables, for example in the shell rc file:
| Variable | Description | Default | Available options |
|---|---|---|---|
PURSE_CLIP | clipboard to use | xclip | pbcopy on macOS |
PURSE_CLIP_ARGS | arguments to pass to clipboard command | unset (disabled) | -i -selection clipboard to use primary (control-v) clipboard with xclip |
PURSE_TIME | seconds to clear password from clipboard/screen | 10 | any valid integer |
PURSE_LEN | default generated password length | 14 | any valid integer |
PURSE_COPY | copy password to clipboard before write | unset (disabled) | 1 or true to enable |
PURSE_DAILY | create daily backup archive on write | unset (disabled) | 1 or true to enable |
PURSE_ENCIX | encrypt index for additional privacy; 2 YubiKey touches will be required for separate decryption operations | unset (disabled) | 1 or true to enable |
PURSE_COMMENT | unencrypted comment to include in index and safe files | unset | any valid string |
PURSE_CHARS | character set for passwords | [:alnum:]!?@#$%^&*();:+= | any valid characters |
PURSE_DEST | password output destination, will set to screen without clipboard | clipboard | clipboard or screen |
PURSE_ECHO | character used to echo password input | * | any valid character |
PURSE_SAFE | safe directory name | safe | any valid string |
PURSE_INDEX | index file name | purse.index | any valid string |
PURSE_BACKUP | backup archive file name | purse.$hostname.$today.tar | any valid string |
[!NOTE] For privacy, the recipient key ID is not included in metadata (using the GnuPG
throw-keyidsoption).