brew install gpg
,它已经安装了gpg2
和gpg-agent
。我已经从旧的mac上复制了我的密钥~.gnupg
。我不会像在旧机器上一样安装mac接口GPG Suite,因为我更喜欢使用命令行。
我已经根据需要设置了我的git全局变量。
git config --global user.name "Christopher Allen"
git config --global user.email "ChristopherA@LifeWithAlacrity.com"
git config --global user.mail "ChristopherA@LifeWithAlacrity.com"
git config --global user.signingKey F8D36C91357405ED
当我尝试向一个需要git config commit.gpgsign=true
的git仓库提交更改时,使用旧版的GPG Suite会弹出一个窗口要求输入密码。然而,只使用GPG时,它可以正确找到我的公钥,但不会提示我输入签名密码。
$ git commit -S -m "changed code"
You need a passphrase to unlock the secret key for
user: "Christopher Allen <ChristopherA@LifeWithAlacrity.com>"
4096-bit RSA key, ID 357405ED, created 2015-04-16
error: gpg failed to sign the data
fatal: failed to write commit object
$
在这里进行研究,我唯一看到的提到问题是在“我无法让`git tag -s`要求我的GPG密码”中,它表明问题出现在
gpg-agent
的环境变量上(没有建议的解决方案),或者使用gpg-preset-passphrase函数(我不想使用该函数)。进一步检查发现,
gpg-agent
没有运行: $ gpg-agent
gpg-agent: no gpg-agent running in this session
我发现了这个网页 https://blog.chendry.org/2015/03/13/starting-gpg-agent-in-osx.html,建议将以下脚本添加到 .bash_profile 中:
[ -f ~/.gpg-agent-info ] && source ~/.gpg-agent-info
if [ -S "${GPG_AGENT_INFO%%:*}" ]; then
export GPG_AGENT_INFO
else
eval $( gpg-agent --daemon --write-env-file ~/.gpg-agent-info )
fi
在获取此脚本后,gpg-agent
会提示:
$ gpg-agent
gpg-agent: gpg-agent running and available
然而,我仍然面临着同样的问题。
有没有什么想法可以解决这个问题呢?我不想使用旧的GPG Suite,回退到GPG 1.0,或者使用gpg-preset-passphrase。
谢谢!
-- Christopher Allen
WARNING: "--write-env-file" is an obsolete option - it has no effect
- 你不知道有什么替代方法吗? - Fyodorexport GPG_TTY=$(tty)
对我很有用,谢谢! - abukaj