GitHub最近宣布了经过验证的提交,因此我借此机会实施了GPG并开始使用密钥.当我想开始提交时,我得到以下内容:
$ git commit
You need a passphrase to unlock the secret key for
user: "John Doe <johndoe@email.com>"
4096-bit RSA key, ID ABCD1234, created 2016-04-08
gpg: problem with the agent - disabling agent use
error: gpg failed to sign the data
fatal: failed to write commit object
Run Code Online (Sandbox Code Playgroud)
我上网搜索了一个解决方案,一个站点(对于邮件提供商)建议killall gpg-agent,并且它有效.现在,我可以输入我的密码来签署提交.
有gpg-agent必要吗?当我安装它时似乎带有GPG,但是如果我必须杀死它以签署我的提交,那么似乎我有一些我不理解的东西.我如何解决这个问题,以便我可以gpg-agent运行并能够签署我的提交?
eri*_*ers 20
我gpg-agent今天才知道如何在我的Mac上使用它.在遇到与您相同的错误后我被阻止:
gpg: problem with the agent - disabling agent use
Run Code Online (Sandbox Code Playgroud)
对于我的设置,我能够通过安装pinentry-mac并指向gpg-agent使用它来修复此问题,从而根据需要弹出GUI提示.
1. install pinentry-mac
% brew install pinentry-mac
2. update gpg-agent conf
# manually change ~/.gnupg/gpg-agent.conf's pinentry-program to /usr/local/bin/pinentry-mac
3. update shell's view of PATH contents
% hash -r
4. restart gpg-agent
# however you normally do it (see below for how I run it manually)
Run Code Online (Sandbox Code Playgroud)
我通过gpg-agent手动重启来调试它.我首先评论了配置~/.gnupg/gpg-agent.conf,然后我运行此命令重新启动gpg-agent --verbose:
% killall gpg-agent && \
eval $(gpg-agent --pinentry-program /usr/local/bin/pinentry --default-cache-ttl 60 --daemon --verbose)
Run Code Online (Sandbox Code Playgroud)
然后我运行了一个测试命令,看到了我们上面列出的错误,以及一个新错误:
# update the MY_GPG_KEY_ID as appropriate
% echo hi | gpg -e -r $(MY_GPG_KEY_ID) | gpg -d --use-agent
...
gpg-agent[60604]: command get_passphrase failed: Device not configured
gpg: problem with the agent - disabling agent use
...
Run Code Online (Sandbox Code Playgroud)
我最终意识到(在阅读了这篇文章和这个GPG页面之后)GPG_TTY并没有按照我开始的步骤设置gpg-agent.所以,一旦我设置了变量,一切都"有效":
% killall gpg-agent && \
eval $(gpg-agent --pinentry-program /usr/local/bin/pinentry --default-cache-ttl 60 --daemon --verbose)
% export GPG_TTY=`tty`
# Now the below command succeeds
% echo hi | gpg -e -r $(MY_GPG_KEY_ID) | gpg -d --use-agent
Run Code Online (Sandbox Code Playgroud)
在这个练习中,我尝试了很多不同的选项,并发现pinentry-macGUI提示符"正常工作".
如果您不想弹出GUI提示符,那么我认为确保在每个终端中设置以下env变量就足够了:
GPG_TTY
export GPG_TTY=$(tty)GPG_AGENT_INFO