如何创建 GPG 密钥并添加到 GitHub
首先,列出您的 GPG 密钥
# If folders does not exist will create be related automatically
$ gpg --list-keys
gpg: directory '/home/ubuntu/.gnupg' created
gpg: keybox '/home/ubuntu/.gnupg/pubring.kbx' created
gpg: /home/ubuntu/.gnupg/trustdb.gpg: trustdb created
$ gpg --list-key
二、生成GPG密钥
$ gpg --gen-key
gpg (GnuPG) 2.2.19; Copyright (C) 2019 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Note: Use "gpg --full-generate-key" for a full featured key generation dialog.
GnuPG needs to construct a user ID to identify your key.
Real name: shenxianpeng
Email address: xianpeng.shen@gmail.com
You selected this USER-ID:
"shenxianpeng <xianpeng.shen@gmail.com>"
Change (N)ame, (E)mail, or (O)kay/(Q)uit? O
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
gpg: key 5F72A7D009FC935A marked as ultimately trusted
gpg: directory '/home/ubuntu/.gnupg/openpgp-revocs.d' created
gpg: revocation certificate stored as '/home/ubuntu/.gnupg/openpgp-revocs.d/F0F32CB8C65536ECE0187EAD5F72A7D009FC935A.rev'
public and secret key created and signed.
pub rsa3072 2022-07-28 [SC] [expires: 2024-07-27]
F0F32CB8C65536ECE0187EAD5F72A7D009FC935A
uid shenxianpeng <xianpeng.shen@gmail.com>
sub rsa3072 2022-07-28 [E] [expires: 2024-07-27]
三、获取你的公钥内容
# get with your email
gpg --armor --export xianpeng.shen@gmail.com
# or with your pub key id
pg --armor --export F0F32CB8C65536ECE0187EAD5F72A7D009FC935A
#
# public key content output below
#
四、将公钥内容(GPG keys)添加到GitHub
打开 GitHub,设置 -> SSH 和 GPG 密钥 -> 新建 GPG 密钥
然后当你使用 command 提交时 git commit -S -m "Your commit message"
,经过验证的签名将显示在 GitHub 上
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论