使用 GPG 为极狐GitLab git commit 签名

本文介绍了如何使用GPG为GitLab的git commit签名,包括生成GPG keypair、在GitLab中添加public key、配置Git、进行commit以及验证签名的过程,确保代码提交的安全性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

目录

git commit 签名

GPG key 生成

使用 GPG 为极狐GitLab git commit 签名

在极狐GitLab 中添加 GPG public key

配置 Git

进行 Git 提交

查看签名信息


git commit 签名

git commit 签名是对 git 的 commit 信息进行一个验证,确保代码提交者是代码修改者本身,防止恶意提交,保护代码的安全。git 有自身的扩展,用来对 commit 进行签名,比如使用 gpg 即可完成 commit 签名。

GPG key 生成

执行 gpg --full-generate-key 即可生成一对 gpg key pair:

gpg --full-generate-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.

Please select what kind of key you want:
   (1) RSA and RSA (default)
   (2) DSA and Elgamal
   (3) DSA (sign only)
   (4) RSA (sign only)
  (14) Existing key from card
Your selection? 1
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (3072) 4096
Requested keysize is 4096 bits
Please specify how long the key should be valid.
         0 = key does not expire
      <n>  = key expires in n days
      <n>w = key expires in n weeks
      <n>m = key expires in n months
      <n>y = key expires in n years
Key is valid for? (0) 1y
Key expires at Wed Jun 28 21:45:26 2023 CST
Is this correct? (y/N) y

GnuPG needs to construct a user ID to identify your key.

Real name: xiaomage
Email address: devops008@sina.com
Comment: gpg signature git commit
You selected this USER-ID:
    "xiaomage (gpg signature git commit) <devops008@sina.com>"

Change (N)ame, (C)omment, (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 C9DE119E4E550644 marked as ultimately trusted
gpg: directory '/root/.gnupg/openpgp-revocs.d' created
gpg: revocation certificate stored as '/root/.gnupg/openpgp-revocs.d/9D6DA2C807767AD9ECB335AEC9DE119E4E550644.rev'
public and
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值