33个版本
0.5.1 | 2024年3月17日 |
---|---|
0.5.0 | 2023年1月19日 |
0.4.1 | 2023年1月11日 |
0.3.5 | 2022年8月18日 |
0.1.2 | 2020年11月9日 |
#288 在 身份验证
在 3 crate中使用
170KB
3K SLoC
prs
使用GPG和git同步的,安全、快速且方便的密码管理器CLI。
prs
是一个用于终端的安全、快速且方便的密码管理器。它使用 GPG 来安全地存储您的机密信息,并集成 git
以实现多台机器之间的自动同步。它还提供内置的密码生成器、收件人管理、历史记录跟踪、回滚、维护工具、Tomb支持等。
这里没有看到演示?在 asciinema 上查看。
prs
受 pass
启发,并使用相同的文件结构,并添加了一些功能。因此,prs
可以与 pass
以及其他所有兼容的客户端、扩展和迁移脚本一起使用。
特性
- 功能全面、快速且友好的命令行工具
- 临时将机密信息复制到剪贴板
- 使用经过战斗考验的 GPG 来保护您的机密信息
- 支持与
git
自动同步,包括历史记录跟踪 - 支持多台机器,并提供简单的收件人管理
- 使用您默认的编辑器轻松编辑机密信息
- 支持智能别名、属性选择
- 与
pass
兼容* - 支持Linux、macOS、Windows、FreeBSD等,支持X11和Wayland
- 支持多个加密后端(未来将支持更多后端和加密)
- 无缝支持 Tomb,以防止元数据泄露*
- 支持用于双因素认证的TOTP令牌
- 可使用
-y
、-f
、-I
标志进行脚本化 - 精确且有用的错误报告
prs
包含一些令人惊叹的调整和优化
- 通过
git
与连接重用,大大提高了同步速度* - 通过
skim
进行超级快速的交互式密钥/接收者选择 - 防止干扰您的剪贴板,没有意外的覆盖或剪贴板丢失
- 使用Tomb时,它会自动为您打开、关闭和调整大小
- 命令有简短且传统的别名,以便更快、更方便地使用
- 使用安全最佳实践(密钥:清零,
mlock
,madvice
,无格式,等等)
使用方法
# Show useful commands (based on current password store state)
prs
# Easily add, modify and remove secrets with your default editor:
prs add site/gitlab.com
prs edit site/gitlab.com
prs duplicate my/secret extra/secret
prs alias my/secret extra/alias
prs move my/secret extra/secret
prs remove site/gitlab.com
# Or generate a new secure password
prs generate site/gitlab.com
# Temporary show or copy secrets to clipboard:
prs show
prs show site/gitlab.com
prs copy
prs copy site/gitlab.com
# Manually synchronize password store with remote repository or do some housekeeping
prs sync
prs housekeeping
prs housekeeping run
prs housekeeping recrypt
# Manage recipients when using multiple machines
prs recipients add
prs recipients list
prs recipients remove
prs recipients generate
prs recipients export
# Commands support shorter/conventional commands and aliases
prs a secret # add
prs c # copy
prs s # show
prs rm # remove
prs yeet # remove
# List all commands and help
prs help
要求
- Linux、macOS、FreeBSD、Windows(其他BSD可能也适用)
- 终端 😎
- 还有
推荐
- 运行:
git
,gnupg
,gpgme
- Ubuntu、Debian及其衍生版:
apt install git gpg libgpgme11 tomb
- CentOS/Red Hat/openSUSE/Fedora:
yum install git gnupg gpgme
- Arch:
pacman -S git gnupg gpgme tomb
- Alpine:
apk add git gnupg gpgme
- macOS:
brew install gnupg gpgme
- Windows:
scoop install git gpg fzf
- Ubuntu、Debian及其衍生版:
- 构建:
git
,gnupg
,gpgme
开发包和开发工具- Ubuntu、Debian及其衍生版:
apt install git gpg build-essential pkg-config python3 xorg-dev libx11-xcb-dev libdbus-1-dev libgpgme-dev tomb
- CentOS/Red Hat/openSUSE/Fedora:
yum install git gnupg gpgme-devel pkgconfig python3 xorg-x11-devel libxcb-devel
- Arch:
pacman -S git gnupg gpgme pkgconf python3 xorg-server libxcb tomb
- Alpine:
apk add git gnupg gpgme-dev pkgconfig
- macOS:
brew install gnupg gpgme
- Windows:
scoop install git gpg fzf
- Ubuntu、Debian及其衍生版:
特定
以下列出的特定功能或crate需要特定的依赖项。
列出的依赖项可能不正确或不完整。如果您认为存在错误,请随时贡献。
[必需] 最小要求
- 运行和构建:
gpg
和git
- Ubuntu、Debian及其衍生版:
apt install git gpg
- CentOS/Red Hat/openSUSE/Fedora:
yum install git gnupg
- Arch:
pacman -S git gnupg
- Alpine:
apk add git gnupg
- macOS:
brew install gpg
- Windows:
scoop install git gpg fzf
- Ubuntu、Debian及其衍生版:
[推荐] 功能:GPGME后端
--feature=backend-gpgme
- 运行:
gpgme
和构建工具- Ubuntu、Debian及其衍生版:
apt install libgpgme11
- CentOS/Red Hat/openSUSE/Fedora:
yum install gpgme
- Arch:
pacman -S gpgme
- Alpine:
apk add gpgme
- macOS:
brew install gpgme
- Windows: 不受支持
- Ubuntu、Debian及其衍生版:
- 构建: _
gpgme
开发包- Ubuntu, Debian 及其衍生版本:
apt install build-essential pkg-config libgpgme-dev
- CentOS/Red Hat/openSUSE/Fedora:
yum install pkgconfig gpgme-devel
- Arch:
pacman -S pkgconf gpgme
- Alpine:
apk add pkgconfig gpgme-dev
- macOS:
brew install gpgme
- Windows: 不受支持
- Ubuntu, Debian 及其衍生版本:
[推荐] 功能:剪贴板
--feature=clipboard
- 运行
- Ubuntu, Debian 及其衍生版本:
apt install xorg libx11-xcb-dev wl-clipboard
- CentOS/Red Hat/openSUSE/Fedora:
yum install pkgconfig xorg libxcb wl-clipboard
- Arch:
pacman -S pkgconf xorg-server python3 libxcb wl-clipboard
- Alpine: ?
- macOS: 无
- Windows: 无
- Ubuntu, Debian 及其衍生版本:
- 构建
- Ubuntu, Debian 及其衍生版本:
apt install build-essential pkg-config python3 xorg-dev libx11-xcb-dev
- CentOS/Red Hat/openSUSE/Fedora:
yum install pkgconfig python3 xorg-x11-devel libxcb-devel
- Arch:
pacman -S pkgconf xorg-server python3 libxcb
- Alpine: ?
- macOS: 无
- Windows: 无
- Ubuntu, Debian 及其衍生版本:
注意: xorg
、libx11-xcb
仅在运行 X11 时需要。 wl-clipboard
仅在运行 Wayland 时需要。
[推荐] 功能:通知
--feature=notify
- 运行
- 构建:
gpgme
开发包- Ubuntu, Debian 及其衍生版本:
apt install libdbus-1-dev
- CentOS/Red Hat/openSUSE/Fedora:
yum install dbus-libs
- Arch:
pacman -S dbus
- Alpine:
apk add dbus
- macOS: 无
- Windows: 无
- Ubuntu, Debian 及其衍生版本:
功能:Tomb
--feature=tomb
客户端:GTK3 客户端
crate: prs-gtk3
@ ./gtk3
- 运行:
gtk3
- Ubuntu、Debian及其衍生版:
apt install libgtk-3-0 libgl1-mesa0
- CentOS/Red Hat/openSUSE/Fedora:
yum install gtk3
- Arch:
pacman -S gtk3
- Alpine:
apk add gtk+3.0 --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main
- macOS:
brew install gtk+3
- Windows: 不受支持
- Ubuntu、Debian及其衍生版:
- 构建:
gtk3
开发包- Ubuntu、Debian及其衍生版:
apt install libgtk-3-dev libgl1-mesa-dev
- CentOS/Red Hat/openSUSE/Fedora:
yum install gtk3-devel
- Arch:
pacman -S gtk3
- Alpine:
apk add gtk+3.0-dev --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main
- macOS:
brew install gtk+3
- Windows: 不受支持
- Ubuntu、Debian及其衍生版:
安装
由于 prs
还处于早期阶段,目前只能提供有限的安装选项。欢迎贡献。
请确保您满足并安装了 '运行' 要求。
请参阅以下针对操作系统/发行版的特定说明
Linux(所有发行版)
目前提供的安装选项有限。请参阅以下列表。或者,您可以使用 预构建的二进制文件 手动安装。
仅提供 64 位 (x86_64
) 包和二进制文件。对于其他架构和配置,您可以从源代码 编译。
将很快提供更多包选项。
Linux:Arch AUR 包
» prs
(从源代码编译,最新发布版)
» prs-git
(从源代码编译,最新 master
提交)
yay -S prs
# or
aurto add prs
sudo pacman -S prs
# or using any other AUR helper
prs --help
Linux:预构建的二进制文件
请查看 Linux 二进制文件的最新发布版资源 这里。
使用 prs--v*-linux--x64--static
二进制文件,以最大限度地减少出现问题的机会。如果尚不可用,您可以使用 上一个版本 中的工件,直到它可用。
在继续之前,请确保您满足并安装了 要求。
您必须使二进制文件可执行,并可能希望将其移动到 /usr/local/bin
以方便执行。
# Rename binary to prs
mv ./prs-* ./prs
# Mark binary as executable
chmod a+x ./prs
# Move binary into path, to make it easily usable
sudo mv ./prs /usr/local/bin/
prs
macOS
prs
可以使用 homebrew 安装。
或者,您也可以 从源代码编译。
请确保您已安装 homebrew
,然后运行
brew install prs
prs
注意:此包在发布时不会自动更新,请随时在此 处 贡献。
Windows
推荐使用scoop
软件包。
或者,您也可以使用预编译的二进制文件手动安装。
如果您正在使用Windows Subsystem for Linux,强烈建议您安装预编译的Linux二进制文件。
只提供64位(x86_64
)的二进制文件。对于其他架构和配置,您可能需要从源代码编译。
Windows: scoop软件包
请确保您已经安装了scoop
,然后运行
scoop install prs
prs
Windows: 预编译的二进制文件
查看最新发布版中的Windows二进制文件资源。使用prs-v*-windows
二进制文件。如果它暂时不可用,您可以使用早期版本中的二进制文件,直到它可用。
您可以在同一目录下使用prs
命令行
.\prs.exe
为了使它可以通过prs
全局调用,您必须将二进制文件添加到系统的PATH
中。
其他
在最新发布页面找到最新二进制文件
注意:对于Linux,如果可用,推荐使用GNU(而不是musl)二进制文件,因为它有更好的剪贴板/通知支持。
# download binary from any source above
# make executable
chmod a+x ./prs
# optional: make globally executable
mv ./prs /usr/local/bin/prs
./prs --help
构建
自己编译和安装prs
需要以下内容
- Rust 1.65或更高版本(MSRV)
- “构建”需求。
macOS或Windows上可能不支持所有功能。默认配置应该可以工作。在更改编译时功能时,请确保检查兼容性。请参阅编译器功能。
编译和安装
要使用默认功能编译和安装prs
,请按照以下步骤操作
-
直接从cargo编译和安装
# Compile and install from cargo cargo install prs-cli -f # Start using prs prs --help
-
或者克隆仓库并使用
cargo
安装# Clone the project git clone https://github.com/timvisee/prs.git cd prs # Compile and install cargo install --path cli -f # Start using prs prs --help # or run it directly from cargo cargo run --release --package prs-cli -- --help # or invoke release binary directly ./target/release/prs --help
编译功能/使用标志
为prs
提供了不同的使用标志,以切换是否包含各种功能和加密后端。以下是一些可用功能,其中一些默认启用
功能 | 在 | 启用 | 描述 |
---|---|---|---|
alias |
prc-cli |
默认 | 支持秘密别名(在Windows上部分支持) |
clipboard |
prs-cli |
默认 | 剪贴板支持:将秘密复制到剪贴板 |
notify |
prs-cli ,prs-gtk3 |
默认 | 通知支持:在剪贴板清除时通知 |
tomb |
all | 默认 | Tomb对密码存储的支持(仅在Linux上支持) |
totp |
prs-cli |
默认 | 对2FA的TOTP令牌支持 |
backend-gpgme |
all | 使用GPGME的GPG加密后端(在Windows上不受支持) | |
backend-gnupg-bin |
all | 默认 | 使用GnuPG二进制的GPG加密后端 |
select-skim |
prc-cli |
默认 | 通过skim进行交互式选择(在Windows上忽略) |
select-skim-bin |
prs-cli |
通过外部skim 二进制文件进行交互式选择 |
|
select-fzf-bin |
prs-cli |
默认 | 通过外部fzf 二进制文件进行交互式选择 |
要在构建或安装期间启用功能,请使用--features <features...>
指定它们,当使用cargo
时。您可能希望首先使用--no-default-features
禁用默认功能。以下是一些示例
# Default set of features with backend-gnupg-bin, install or build, one of
cargo install --path cli --features backend-gnupg-bin
cargo build --path cli --release --features backend-gnupg-bin
# No default features, except required, one of
cargo install --path cli --no-default-features --features backend-gpgme
cargo install --path cli --no-default-features --features backend-gnupg-bin
# With alias, clipboard and notification support, one of
cargo install --path cli --no-default-features --features backend-gpgme,alias,clipboard,notify
cargo install --path cli --no-default-features --features backend-gnupg-bin,alias,clipboard,notify
安全
安全由全球使用的gpg
提供支持,它已经经过超过20年的实战检验。
总结来说,在假设以下条件时,prs
是安全的,可以用来保存你的最深层次的秘密:
- 你确保密码存储目录(
~/.password-store
)的安全 - 在使用与
git
同步时:确保你的远程仓库安全 - 你使用安全的GPG密钥
- 你的机器是安全的
秘密内容是加密并安全的。秘密以加密的GPG文件的形式存储。但是,一些元数据在未解密的情况下是可见的。当你有权限访问密码存储目录时,可以查看秘密的名称(文件名)、修改时间(文件修改时间)和加密大小(文件大小)。为了防止这种元数据泄露,你可以使用Tomb。
prs
使用了安全最佳实践来防止意外泄露任何秘密数据。在这里,敏感数据如明文、密文等被称为“秘密”。
秘密是/被
- 在删除时置零
- 锁定在物理内存中,不能泄露到交换/磁盘(
mlock
) - 锁定在内存中,不能被转储/不包括在核心中(
madvice
) - 编辑时不写入磁盘(如果可能)
- 阻止字符串格式化
- 使用恒定时间比较以防止基于时间的攻击
- 最小化克隆
防止秘密泄露的保护有其局限性,特别是
prs show
将秘密数据打印到stdoutprs edit
如果不可用安全位置(如/dev/shm
),则可能在磁盘上存储秘密到一个安全的临时文件,然后打开它在你默认的编辑器中,并在之后删除它prs copy
将秘密数据复制到你的剪贴板,并在20秒后清除
参考:[XKCD 538](https://xkcd.com/538/)
注意:prs
不提供任何形式的担保,对于由于秘密泄露或其他问题造成的损害不承担任何责任。
常见问题解答
prs
是否安全?prs
有多安全?
请阅读安全部分。
如何使用git进行同步?
如果你已经有了与prs
兼容的远程密码存储库,使用以下命令克隆它:
# Clone existing remote password store, automatically enables sync
prs clone MY_GIT_URL
# List secrets
prs list
如果你还没有远程密码存储库,可以创建一个(例如,GitHub或GitLab上的一个空私有仓库),然后运行以下命令:
# Initialize new password store (if you haven't done so yet)
prs init
# Initialize sync functionality (if you haven't done so yet)
prs sync init
# Set your remote repository URL and sync to push your password store
prs sync remote MY_GIT_URL
prs sync
当你的密码存储启用同步时,所有修改你的秘密的命令将自动保持你的远程存储同步。
由于你在另一台机器上编辑了一个秘密,需要手动触发同步,请运行
prs sync
如何在多台机器上使用prs
并在它们之间同步?
注意:在新的/附加机器上添加和使用现有的密码存储需要你在设置期间能够访问使用该存储的机器。
首先,你必须在一台机器上有一个密码存储。如果你还没有,请使用prs init
创建一个。你必须为此密码存储设置与远程git仓库的同步,请参阅如何使用git进行同步部分。
要在新机器上使用你的现有密码存储,请安装prs
并克隆你的远程密码存储
# On new machine: clone existing password store from git remote
prs clone MY_GIT_URL
然后为您的新机器添加一个收件人到密码存储中。我强烈建议为每台机器使用一个新的收件人(GPG密钥对)(这样您就不必共享秘密的GPG密钥)。添加现有的秘密GPG密钥作为收件人,或使用以下方法生成新的GPG密钥对:
# On new machine: add existing recipient or generate new one
prs recipients add --secret
# or
prs recipients generate
由于尚未为新收件人加密,您的新机器目前无法读取任何密码存储的秘密。回到您已经使用存储的现有机器,并重新加密所有秘密,以便为新收件人加密。
# On existing machine: re-encrypt all secrets
prs housekeeping recrypt --all
这可能需要一些时间。完成后,在新机器上同步以拉取更新的秘密。
# On new machine: pull in all re-crypted secrets
prs sync
# You're done!
prs list
如何在移动设备上使用prs
?
prs
本身不支持移动设备,但您可以使用兼容的客户端在移动设备上使用密码存储。
请参阅pass
网站的兼容客户端。
如果我丢失了密钥,能否恢复我的秘密?
不,如果您丢失了所有密钥,就没有方法恢复您的秘密。
如果您的机器崩溃或重新安装操作系统,您可能会丢失密钥(收件人、GPG秘密密钥)。
如果您在多台机器上使用git同步相同的密码存储,您仍然可以读取其他机器上的秘密。要重新添加您丢失密钥的机器,请从该机器上删除密码存储,并查看本节。
什么是Tomb?
Tomb是一种文件加密系统。它可以与prs
一起使用,以防止您的密码存储的元数据泄露。
使用Tomb与prs
时,您的密码存储存储在一个加密文件中。prs
会根据需要自动为您打开和关闭密码存储Tomb。这使得恶意程序列出您的密码存储内容变得更加困难。
此功能灵感来源于pass-tomb
,这是为Tomb提供支持的pass
扩展。在prs
中,此功能是内置的。
注意:Tomb仅在Linux上受支持。
如何使用Tomb?
prs
在Linux系统上内置了对Tomb的支持。请确保prs
是用tomb
功能编译的,并且Tomb已安装。
要初始化当前密码存储的Tomb,只需调用
# Initialize tomb, this may take some time
prs tomb init
# Read tomb status
prs tomb status
要在一个Tomb中初始化新的密码存储,首先初始化密码存储,然后初始化Tomb。
# Initialize new password store
prs init
# ...
# Initialize tomb, this may take some time
prs tomb init
如果您已经使用pass-tomb
创建了一个Tomb,则无需采取任何操作。prs
对其提供了无缝支持,并应自动为您管理它。通过调用prs tomb status
来确认它是否已检测到。
如何在多台机器上使用Tomb?
Tomb是本地存储在您的机器上,不进行同步。要在多台机器上使用Tomb,您必须在每台机器上初始化它。
只需在您尚未使用Tomb的机器上运行prs tomb init
,并在新机器上克隆您的密码存储后执行此操作。
prs
与pass
兼容吗?
是的。
prs
使用与pass
相同的文件结构。其他pass
客户端应该能够查看和编辑您的秘密。
prs
会添加额外的文件和设置,一些 prs
功能可能与其他 pass
客户端不兼容。
虽然底层文件结构兼容,但命令行界面不兼容,并且与 pass
不同。这是为了消除歧义并提高整体可用性。
有关兼容的 pass
客户端的列表,请参阅此处。
帮助
$ prs help
prs 0.5.1
Tim Visee <3a4fb3964f@sinenomine.email>
Secure, fast & convenient password manager CLI with GPG & git sync
Usage: prs [OPTIONS] [COMMAND]
Commands:
show Display a secret
copy Copy secret to clipboard
generate Generate a secure secret
add Add a secret
edit Edit a secret
duplicate Duplicate a secret
alias Alias/symlink a secret
move Move a secret
remove Remove a secret
list List all secrets
grep Grep all secrets
init Initialize new password store
clone Clone existing password store
sync Sync password store
slam Aggressively lock password store & keys preventing access (emergency)
totp Manage TOTP tokens
recipients Manage store recipients
git Invoke git command in password store
tomb Manage password store Tomb
housekeeping Housekeeping utilities
help Print this message or the help of the given subcommand(s)
Options:
-f, --force Force the action, ignore warnings
-I, --no-interact Not interactive, do not prompt
-y, --yes Assume yes for prompts
-q, --quiet Produce output suitable for logging and automation
-v, --verbose... Enable verbose information and logging
-s, --store <PATH> Password store to use [env: PASSWORD_STORE_DIR=]
--gpg-tty Instruct GPG to ask passphrase in TTY rather than pinentry
-h, --help Print help
-V, --version Print version
许可
本项目采用 GNU GPL-3.0 许可证发布。有关更多信息,请查看LICENSE 文件。
本项目的库部分采用 GNU LGPL-3.0 许可证。有关更多信息,请查看lib/LICENSE 文件。
依赖项
~4–14MB
~191K SLoC