32个版本
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日 |
#126 在 身份验证
215KB
3.5K 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 及其衍生版:
特定
以下列出的特定功能或软件包需要特定的依赖项。
列出的依赖项可能不正确或不完整。如果您认为存在错误,请随时贡献。
[必需] 最小要求
- 运行和构建:
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
- 架构:
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 及其衍生版:
功能:墓碑
--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
安全性
安全由全球范围内使用并经过20多年实战检验的 gpg
支持。
总结来说,在假设以下条件时,prs
可以安全地保管您的最深层次秘密:
- 您确保密码存储目录(
~/.password-store
)安全 - 使用与
git
同步时:您确保远程仓库安全 - 您使用安全的 GPG 密钥
- 您的机器安全
秘密的内容经过加密并得到保护。秘密以加密的 GPG 文件形式存储。然而,某些元数据在未经解密的情况下是可见的。当您有权访问密码存储目录时,秘密的名称(文件名)、修改时间(文件修改时间)和加密大小(文件大小)是可见的。为了防止这种元数据泄露,您可以使用 Tomb。
prs
中使用了安全最佳实践来防止意外泄露任何秘密数据。在这里,将如明文、密文等敏感数据称为“秘密”。
秘密是/使用
- 在丢弃时清零
- 锁定到物理内存,不能泄露到交换/磁盘(
mlock
) - 锁定在内存中,不能被转储/不包含在核心中(
madvice
) - 不写入磁盘以编辑(如果可能)
- 阻止字符串格式化
- 使用恒定时间比较以防止基于时间的攻击
- 尽可能少地克隆
防止泄露秘密的保护有其局限性,特别是
prs show
将秘密数据打印到 stdoutprs edit
可能会在磁盘上存储一个安全的临时文件以存储秘密,如果(如/dev/shm
)等安全位置不可用,然后它将在您的默认编辑器中打开它,并在之后删除它prs copy
将秘密数据复制到您的剪贴板,并在20秒后清除
参考:XKCD 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 文件。
依赖项
~19–49MB
~896K SLoC