【问题标题】:Git does not ask me for gpg passphrase and fails my commitGit 没有要求我输入 gpg 密码并且我的提交失败
【发布时间】:2017-02-11 06:11:21
【问题描述】:

当我执行git commit -a -S -m "Commit Message" 时,我收到此错误:

You need a passphrase to unlock the secret key for
user: "Username (Gpg Key) <email-id>"
2048-bit RSA key, ID 2487BE7C, created 2016-10-03

error: gpg failed to sign the data
fatal: failed to write commit object

但是,当我提交时,它甚至不会询问/提示我的密码。那么,在使用 gpg 的 -S 标志时,如何以及在何处输入我的密码?

【问题讨论】:

  • 你确定 gpg 可以读取输入吗?如果标准输入已关闭,您将看到上述错误消息。如果 git 命令没有在交互式 shell 中运行,那么您可能需要运行 gpg-agent 才能处理密码输入。
  • @G.Sliepen 请告诉我如何启动它?

标签: git gnupg


【解决方案1】:

我也有类似的情况。我有 gpg 和 gpg2 二进制文件,它们都指向 GPG 版本 2.0.30。系统没有提示我输入密码。

在您的 bash 配置文件中(我在 .zshrc 文件中完成)添加以下行:

export GPG_TTY=$(tty)

【讨论】:

  • 非常感谢,这适用于我在 macOS 上的 bash。
  • 忘记了所有关于.zshrc 的内容我一直在其他帖子中尝试过,但在我的.bashrc 中,哎呀!这工作,谢谢!
【解决方案2】:

它停止提示我,所以我不得不杀死守护进程

ps aux | grep gpg
mark              3129   0.0  0.0  4397952    820   ??  Ss    8Mar19   0:28.84 gpg-agent --homedir /Users/Mark/.gnupg --use-standard-socket --daemon
mark             18137   0.0  0.0  4286492    848 s000  R+    3:43pm   0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn gpg

然后

sudo kill -9 3129

然后它起作用了。这可能是一个稍微不同的问题。

【讨论】:

  • 这为我解决了这个问题。好像我以一种糟糕的方式退出了前一个提示,这让守护进程感到困惑。
  • 谢谢。
【解决方案3】:

如果您使用的是 OSX。似乎 gpg 更新(brew)更改为 gpg 到 gpg1 的位置,您可以更改 git 查找 gpg 的二进制文件:

git config --global gpg.program gpg1

this medium blog post

【讨论】:

  • 对我来说它仍然是 gpg 但它不会要求输入密码并失败。还有其他推荐吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-09-16
  • 2016-08-19
  • 2014-04-26
  • 1970-01-01
  • 1970-01-01
  • 2011-12-08
相关资源
最近更新 更多