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 <应该放什么>
?
我有一个类似的第二个问题。如果在一年后我格式化我的电脑并且失去了我的密钥,我将没有办法验证那些提交仍然属于我。是否有一个好的标准可以将该密钥保存在其他地方,而不仅仅是将其丢到某个在线驱动器中(我很可能会失去它)?
编辑:我至少成功让gpg工作了。按照Git错误-gpg无法签署数据,我的gpg出现了问题:gpg: 签名失败: 设备不当的 ioctl 操作 gpg: [stdin]: clear-sign 失败: 设备不当的 ioctl 操作
然后从在Maven上使用MacOS的“gpg:签名失败:设备不当的ioctl操作”中添加export GPG_TTY=$(tty)
到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上查看时: 现在我一点想法都没有了。