pwd.sh

drduhMIT活跃维护

用 Bash 和 GnuPG 对称加密管理密码与机密信息,把密钥库放在一个加密文件里,靠命令行完成增删查改,适合不想依赖图形界面或云端服务的人。

Manage secrets with Bash and GnuPG symmetric encryption

v4发布于 2026-08-24 01:00 UTC1,564star132fork同步于 2026-11-10 23:48 UTC

怎么上手

由 README 提炼,执行前请确认
git clone https://github.com/drduh/pwd.sh
./pwd.sh w userName 20
硬件要求按 README 说明

README 未说明

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

用 Bash 和 GnuPG 对称加密管理密码等文本密钥的轻量脚本

用 Bash 和 GnuPG 对称加密管理密码与机密信息,把密钥库放在一个加密文件里,靠命令行完成增删查改,适合不想依赖图形界面或云端服务的人。

核心能力

  • 每个密钥存为随机命名文件,索引加密映射用户名
  • 索引和密钥文件可脱离脚本直接用 GnuPG 解密
  • 支持写入、读取、列出、随机生成密钥与用户名
  • 按时间戳保留历史版本,默认读取最新版本
  • 可打包 tar 备份并支持环境变量自定义存储与剪贴板

容易踩的坑

依赖 GnuPG 与 Bash 环境,macOS 剪贴板需把 PWDSH_CLIP_CMD 设为 pbcopy;启用 Pepper 后其值不包含在备份中,丢失将无法仅凭口令解密;PWDSH_COMMENT 写入的是未加密注释,勿放敏感信息

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v4
  1. v4Version 4最新正式版2026-08-24 · 2026-08-24 01:00 UTC
    • Version materials with "v4" prefix to improve compatibility
    • Improved output format, timestamped final and error message
    • Remove chmod "lock" on exit - no meaningful benefit from it
    • Menu option to generate username or password without saving
    • Refactor functions for improved reliability and readability

    Full Changelog: https://github.com/drduh/pwd.sh/compare/3.0...v4

  2. 3.0Version 32024-07-05 · 2024-07-05 01:17 UTC
    查看更新说明

    The third stable release of pwd.sh 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 gpg often lacked special character diversity and did not meet website requirements. The character set is now a configurable tr setting to increase password quality.

    Changelist

    • New pepper feature for adding additional entropy to passphrase, see Details for more information. Off by default.
    • 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 tr instead of gpg to 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.
    • Less ambiguous output messages.
    • Copy password to clipboard before unlocking safe.
    • Re-order action list so Read is first.
    • Error handling and readability improvements.

    Full Changelog: https://github.com/drduh/pwd.sh/compare/2.0...3.0

  3. 3.0b1Version 3 Beta 1pre-release2024-03-24 · 2024-03-24 19:43 UTC
    查看更新说明

    Version 3 Beta continues with additional features and reliability improvements.

    Currently in beta testing.

    Changelog:

    • New configuration options available - see README#Configure.
    • Support for unencrypted comment in safe and index files. Off by default.
    • Support for systems without clipboard: passwords will print to screen and clear.
    • Script exits are trapped for chmod cleanup, now 0000.
    • Updated "Clearing password" message.
    • Copy password to clipboard before unlocking safe.
    • Re-order action list so Read is first.
    • Minor error handling and readability improvements.
  4. 3.0bVersion 3 Betapre-release2024-03-10 · 2024-03-10 19:05 UTC
    查看更新说明

    The third release of pwd.sh 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 gpg often lacked special character diversity and did not meet website requirements. The character set is now a configurable tr setting to increase password quality.

    Currently in beta testing.

    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 tr instead of gpg to improve compliance with password requirements.
    • Reduce default password length 20->14 characters, remove maximum limit.
    • Increase filename size 8->10 characters.
    • Explicitly unset password variable after write.
    • Minor code readability improvements.
  5. 2.0Version 22020-05-25 · 2020-05-25 21:53 UTC
    查看更新说明

    The second release of pwd.sh features many security and reliability improvements, and is a recommended upgrade. Compatible on Linux, OpenBSD, macOS.

    Known Issues:

    • Newer versions of macOS error with tr: Illegal byte sequence - see issue #36

    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 pwd.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.

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    pwd.sh is a Bash script to manage text secrets, such as passwords, using GnuPG.

    Each secret is saved to a randomly-named file in a directory. An encrypted index maps usernames to secrets contained in files. Both the index and files can be decrypted directly with GnuPG - without pwd.sh.

    Install

    Download from Releases, or to use the latest version, clone the repository:

    git clone https://github.com/drduh/pwd.sh
    

    Or download the script directly:

    wget https://raw.githubusercontent.com/drduh/pwd.sh/main/pwd.sh
    

    Use

    Run the script interactively using ./pwd.sh or symlink to a directory in PATH:

    • w - write (create) a secret
    • r - read (access) a secret
    • l - list secret names and paths
    • s - generate a random secret
    • u - generate a random username
    • b - archive materials for backup
    • v - print version information
    • h - print help text

    Options can also be passed on the command line.

    Create a 20-character secret for userName:

    ./pwd.sh w userName 20
    

    Read secret for userName:

    ./pwd.sh r userName
    

    Secrets are stored with an epoch timestamp for revision control and the most recent version is read by default. To list all secrets or read a specific version of a secret:

    ./pwd.sh l
    ./pwd.sh r userName@1574723600
    

    Create a backup tar archive:

    ./pwd.sh b
    

    Restore from backup:

    tar xvf pwd*tar
    

    Configuration

    pwd.sh can be configured with environment variables as follows:

    VariableDescriptionDefaultAvailable options
    PWDSH_STOREsecret storage directoryv4-pwd.sh.secretany valid string
    PWDSH_INDEXindex file namev4-pwd.sh.indexany valid string
    PWDSH_CLIP_CMDclipboard to usexclippbcopy on macOS
    PWDSH_CLIP_ARGarguments to pass to clipboard commandunset (disabled)-i -selection clipboard to use primary (control-v) clipboard with xclip
    PWDSH_CLIP_OUTsecret output destination, will set to screen without clipboardclipboardclipboard or screen
    PWDSH_CLIP_SECseconds to clear secret from clipboard/screen10any valid integer
    PWDSH_COPYcopy secret to clipboard before writeunset (disabled)1 or true to enable
    PWDSH_COMMENTunencrypted comment to include in index and secret filesunsetany valid string
    PWDSH_ECHOcharacter used to echo password input*any valid character
    PWDSH_LENdefault secret length20any valid integer
    PWDSH_CHARcharacter set for secretA-Za-z0-9!@#$%^&*()_+any valid characters
    PWDSH_BACKUP_NAMEbackup archive file namev4-pwd.sh.hostname.2026-12-31.tarany valid string
    PWDSH_PEPPERfile containing Pepperunset (disabled)any valid file path

    See config/gpg.conf for recommended GnuPG options.

    Also see drduh/Purse which integrates with YubiKey instead of using a passphrase to access secrets.

    Pepper

    The Pepper is an additional string appended to the storage passphrase to improve its strength. When the PWDSH_PEPPER option is set to a valid path, a secret value is generated and displayed once, then saved to the respective file.

    The Pepper should be written down (for example, transcribed with passphrase.html or passphrase.txt template) and stored in a secure, durable location for backup.

    This feature may enable use of a more memorable - and possibly weaker passphrase - for convenience, while still guarding backups against passphrase brute-force attempts (provided the Pepper is backed up separately).

    The Pepper feature is opt-in and has no effect unless explicitly enabled.

    [!IMPORTANT] The Pepper is not included in backup archives! Without the Pepper, secret storage will not be accessible with the passphrase alone!