Git支持使用GPG签署提交,而GitHub将这些提交显示为“已验证”。单击“已验证”标签时,您将看到类似以下内容的内容:
该提交已使用经过验证的签名进行了签名。
我的用户名
我的名字
GPG密钥ID:
F66DEF7BA82E8647
当您合并一个拉取请求时,或者大概是在Web界面中进行提交时,它也显示为“已验证”,但带有不同的消息:
该提交是在GitHub.com上创建的,并使用GitHub的密钥使用经过验证的签名进行了签名。
GPG密钥ID:4AEE18F83AFDEB23
运行时git log --show-signature
,它将显示我已经在本地签名的提交,如下所示:
gpg: Signature made 01/25/18 11:52:25 W. Europe Standard Time^M
gpg: using RSA key 3FA85DEE7B64EB7EC8F97F41F66DEF7BA82E8647^M
gpg: Good signature from "Dude" <somebody@email.com>" [ultimate]^M
Run Code Online (Sandbox Code Playgroud)
到目前为止,一切都很好。但是,当遇到合并的请求请求时,将得到以下信息:
gpg: Signature made 01/25/18 09:07:45 W. Europe Standard Time^M
gpg: using RSA key 4AEE18F83AFDEB23^M
gpg: Can't check signature: No public key^M
Run Code Online (Sandbox Code Playgroud)
显然,这是因为我尚未将公共密钥添加到我的GPG密钥列表中。问题是:在哪里可以找到此密钥?在某处列出了吗?
编辑:显然我已经尝试过谷歌搜索,甚至在GitHub的社区论坛上提出了一个问题,但是没有得到答复。
根据 GPG 的性质,您需要确定您正在导入哪些密钥以及您签署了哪些密钥。您可以在此处找到 GitHub 的网络流 GPG 公钥:
https://github.com/web-flow.gpg
如果要导入公钥,可以使用以下命令:
curl https://github.com/web-flow.gpg | gpg --import
Run Code Online (Sandbox Code Playgroud)
As a user of GPG, you should evaluate the your level of trust of the source of this key. If you decide that it does indeed belong to GitHub, you can sign it and optionally publish your signature to a key server, essentially publicly acknowledging that you believe the key belongs to who it is supposed to belong to.
GitHub 有关于如何查找现有密钥、创建新密钥、将它们添加到 git、GitHub 等的文档。您可以在这里找到它,我认为它会回答您在这里遇到的任何问题。
来自: https: //help.github.com/articles/about-gpg/
GitHub 将自动签署您使用 GitHub Web 界面所做的提交。这些提交将在 GitHub 上具有经过验证的状态。您可以使用https://github.com/web-flow.gpg上提供的公钥在本地验证签名