【发布时间】:2022-08-24 03:38:06
【问题描述】:
根据 git,您现在可以使用现有的 ssh 密钥签署您的提交。
https://github.blog/2021-11-15-highlights-from-git-2-34/#tidbits
紧随其后:https://unix.stackexchange.com/questions/269188/use-my-ssh-key-to-sign-git-commits。
我也一直在浏览这个文档:https://git-scm.com/docs/git-config#Documentation/git-config.txt-gpgprogram,但是非常不清楚如何使用它。
我已将我的 gpg 格式设置为 ssh 并签名为 true,因此目前它正在尝试对其进行签名并失败。我相信我还需要设置 user.signingKey 但我无法弄清楚格式是什么,即git config --global user.signingKey <what-is-supposed-to-go-here>?
我对此有第二个问题。如果在 1 年后我格式化我的 PC 并丢失了我的密钥,我将无法验证这些提交是否仍然属于我。除了将密钥转储到某个在线驱动器(无论如何我可能会丢失它)之外,是否有一个很好的标准可以将该密钥保存在某个地方?
编辑:我至少设法让 gpg 工作。关注:Git error - gpg failed to sign data,我的 gpg 被打破了:
gpg: signing failed: Inappropriate ioctl for device gpg: [stdin]: clear-sign failed: Inappropriate ioctl for device
然后将export GPG_TTY=$(tty) 从\"gpg: signing failed: Inappropriate ioctl for device\" on MacOS with Maven 添加到bash,最终为我工作,所以它至少使用gpg 对其进行签名。
编辑:以为我设法让它工作,但没有。在https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent 之后,我创建了一个新的 ed25519 ssh 密钥。
之后你需要git config --global gpg.format \"ssh\",以及git config --global user.signingkey \"<key>\"。
我使用ssh-ed25519 ASD9s8df79AASDa8sd79as7d9a8s7d89ASDASD98a7sd98a7sdASA/sd user@domain.io 作为密钥,来自~/.ssh/id_ed25519.pub。
但是后来我去github看看:
现在我已经不知道了。
-
ssh 签名充满了棘手的问题;正如您所看到的,即使 gpg 签名也会遇到问题,而且支持的时间更长,因此人们有更多的时间来找出交互出错的地方。不过,我没有关于让 ssh 签名工作的特别建议。
-
是的,正如你所说,让每一个棘手的部分都工作起来真的很令人沮丧。据我所见,github实际上不支持ssh签名,或者只支持一种非常特定类型的ssh mime,或者它只支持rsa,我不知道。我最终只使用了gpg。
-
见我的edited answer below:GitHub 现在(2022 年 8 月)支持 SSH 提交验证