我正在尝试在 MAC OS 11.2.1 上设置我的 gnupg 配置
到目前为止,我已经设置了我的 SSH,我已经生成了我的 GPG 密钥并将其添加到 GPG 代理中。
现在,如果我运行这个命令:
echo "test" | gpg --clearsign
我得到了这个结果:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
test
gpg: signing failed: No pinentry
gpg: [stdin]: clear-sign failed: No pinentry
问题是,松树的安装如下:
pinentry-curses (pinentry) 1.1.1
Copyright (C) 2016 g10 Code GmbH
License GPLv2+: GNU GPL version 2 or later <https://www.gnu.org/licenses/>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
在我的 gpg-agent.conf 文件中,有以下行:
pinentry-program /usr/local/bin/pinentry-mac
在我的 gpg.conf 中我有以下行:
no-tty
gpg 版本:
gpg (GnuPG) 2.2.27
libgcrypt 1.9.2
Copyright (C) 2021 Free Software Foundation, Inc.
License GNU GPL-3.0-or-later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Home: /Users/usr/.gnupg
Supported algorithms:
Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2
我尝试过多次关闭 gpg 代理并重新安装 gnupg,重新安装 pinentry。但都无济于事。
答案1
命令
brew install pinentry
显然将 pinentry 安装到了与 gpg-agent.conf 文件不同的路径。如果有人遇到此问题,只需执行
which pinentry-mac
并将其提供给您的路径放入 gpg-agent.conf 文件中。
如果目录中没有gpg-agent.conf
找到文件~/.gnupg/
,则创建它。
touch ~/.gnupg/gpg-agent.conf
很重要
更改conf文件后运行gpgconf --kill gpg-agent
。感谢杰瑞米·布莱
答案2
对于配备指纹传感器的 Mac,甚至还有一个更好的工具,称为 pinentry-touchid
如何安装
brew tap jorgelbg/tap
brew install pinentry-touchid
如何设置 gpg
echo pinentry-program $(which pinentry-touchid) >> ~/.gnupg/gpg-agent.conf
要验证配置,您应该看到类似这样的内容:
cat ~/.gnupg/gpg-agent.conf
default-cache-ttl 600
max-cache-ttl 7200
pinentry-program /opt/homebrew/bin/pinentry-touchid