如何在5分钟内配置pinentry-touchid:macOS用户的终极GPG Touch ID指南

发布时间:2026/8/8 20:24:21
如何在5分钟内配置pinentry-touchid:macOS用户的终极GPG Touch ID指南
如何在5分钟内配置pinentry-touchidmacOS用户的终极GPG Touch ID指南【免费下载链接】pinentry-touchidCustom GPG pinentry program for macOS that allows using Touch ID for fetching the password from the macOS keychain.项目地址: https://gitcode.com/gh_mirrors/pi/pinentry-touchidpinentry-touchid是一款专为macOS用户设计的自定义GPG pinentry程序它允许用户通过Touch ID从macOS钥匙串中获取密码为GPG操作带来更便捷、更安全的身份验证体验。了解pinentry-touchid的工作原理 pinentry-touchid与gpg-agent协同工作通过以下规则提供密码当钥匙串中找不到给定密钥的密码条目时程序会回退到pinentry-mac程序获取密码。建议在对话框中取消勾选“Save in keychain”选项防止pinentry-mac存储密码。若找到密码条目用户将看到Touch ID对话框成功验证后存储在钥匙串中的密码将返回给gpg-agent。若找到密码条目但在Touch ID成功验证后该条目不属于pinentry-touchid程序则会显示普通密码对话框。在此对话框中输入密码后点击“Always allow”将允许pinentry-touchid无需额外输入密码即可访问密码条目但密码访问仍受Touch ID保护。快速安装pinentry-touchid的步骤 ⚡安装前的准备工作在安装pinentry-touchid之前需要确保系统已安装以下组件gnupgpinentry-mac如果已经安装了GPG可通过运行以下命令确认执行pinentry时是否显示GUI提示$ echo GETPIN | pinentry若未看到来自pinentry-mac的对话框可通过Homebrew安装$ brew install pinentry-mac然后将pinentry别名指向pinentry-mac$ alias pinentrypinentry-mac若别名设置不足以使gpgconf返回正确路径可执行以下命令自动修复符号链接$ pinentry-touchid -fix通过Homebrew安装推荐作为发布流程的一部分项目提供了更新的Homebrew Formula。执行以下命令使用Homebrew安装pinentry-touchid$ brew tap jorgelbg/tap $ brew install pinentry-touchidHomebrew会显示后续步骤类似如下内容 Caveats ➡️ Ensure that pinentry-mac is the default pinentry program: /usr/local/bin/pinentry-touchid -fix ✅ Add the following line to your ~/.gnupg/gpg-agent.conf file: pinentry-program /usr/local/opt/pinentry-touchid/bin/pinentry-touchid Then reload your gpg-agent: gpg-connect-agent reloadagent /bye Run the following command to disable Save in Keychain in pinentry-mac: defaults write org.gpgtools.common DisableKeychain -bool yes ⛔️ If you are upgrading from a previous version, you will be asked to give access again to the keychain entry. Click Always Allow after the Touch ID verification to prevent this dialog from showing. Summary /usr/local/Cellar/pinentry-touchid/0.0.2: 4 files, 2.2MB, built in 10 seconds手动安装方法从项目的Releases页面下载pinentry-touchid二进制文件。配置gpg-agent使用pinentry-touchid作为pinentry程序。在~/.gnupg/gpg-agent.conf中添加或替换以下行$ pinentry-program /usr/local/bin/pinentry-touchid可将/usr/local/bin/pinentry-touchid替换为二进制文件的实际存储路径。确保pinentry-mac被配置为默认的pinentry程序作为回退。可通过执行以下命令检查默认将使用哪个PIN程序$ pinentry-touchid -check若报告任何错误pinentry-touchid可自动为你修复符号链接$ pinentry-touchid -fix手动将GPG密钥密码添加到钥匙串 首先确保pinentry-mac已在使用钥匙串$ security find-generic-password -s GnuPG若得到一长串属性列表则说明pinentry-mac已配置使用钥匙串。若出现类似以下错误则表示pinentry-mac未配置使用钥匙串security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.配置pinentry-mac在配置pinentry-touchid之前应至少配置pinentry-mac使用钥匙串一次$ defaults write org.gpgtools.common UseKeychain -bool yes确保~/.gnupg/gpg-agent.conf中的pinentry-program条目指向pinentry-mac然后重启GPG Agent$ gpgconf --kill gpg-agent使用gpg时pinentry-mac应会提供GUI提示输入GPG密码$ echo 1234 | gpg -as -确保勾选提示上的“Save in Keychain”框。之后可能会再次提示输入登录密码授权pinentry-mac创建和使用钥匙串条目存储GPG密码。如有此提示选择“Always Allow”以避免未来再次提示。现在应能通过之前的命令看到新的钥匙串条目$ security find-generic-password -s GnuPG配置pinentry-touchid一旦钥匙串配置正确可更新gpg-agent.conf将pinentry-program的正确路径指向pinentry-touchid的完整路径。每次更改此配置文件后记得重启GPG Agent$ gpgconf --kill gpg-agent建议使用以下命令为默认的pinentry-mac程序禁用在macOS钥匙串中存储密码的选项$ defaults write org.gpgtools.common DisableKeychain -bool yes这将允许pinentry-touchid创建并自动获取钥匙串中条目的所有权。如果钥匙串中已存在条目需要始终允许pinentry-touchid访问现有条目。注意事项 ⚠️pinentry-touchid项目不会将密码/pin存储在设备的安全飞地中而是使用来自pinentry-mac如果可用的普通钥匙串条目或创建新的条目。经过测试的设备和系统版本 pinentry-touchid已在以下设备和macOS版本组合上进行了测试MacBook Pro (15-inch, 2018), macOS Catalina - 10.15.7MacBook Pro (15-inch, 2018), macOS Big Sur - 11.4, 11.5.0, 11.5.1MacBook Pro (16-inch, Late 2019), macOS Big Sur - 11.4, 11.5.1MacBook Pro (16-inch, Late 2021), macOS Monterey - 12.2【免费下载链接】pinentry-touchidCustom GPG pinentry program for macOS that allows using Touch ID for fetching the password from the macOS keychain.项目地址: https://gitcode.com/gh_mirrors/pi/pinentry-touchid创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考