其他分享
首页 > 其他分享> > 使用git bash 生成GPG key和配置到idea

使用git bash 生成GPG key和配置到idea

作者:互联网

查看git 版本

git --version
#2.31.1.windows.1

生成GPG key

gpg版本小于gpg (GnuPG) 2.1.17的使用命令:
$ gpg --full-generate-key
一般使用:
$ gpg --gen-key
按提示输入配置信息

Type of the key: RSA
Key size: at least 4096 bits
Key validity period: 1 year (it's a good practice to rotate the key once a year)
$ gpg --full-generate-key
gpg (GnuPG) 2.2.27-unknown; Copyright (C) 2021 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?
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)
Key does not expire at all
Is this correct? (y/N) y

创建用户id 一般和github 保持一致

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

Real name: wjwdive
Email address: wjwdive@163.com
Comment: for github GPG key
You selected this USER-ID:
    "wjwdive (for github GPG key) <wjwdive@163.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 0000000000000000 marked as ultimately trusted
gpg: directory '/c/Users/Administrator/.gnupg/openpgp-revocs.d' created
gpg: revocation certificate stored as '/c/Users/Administrator/.gnupg/openpgp-revocs.d/0000000000000000000000000000000000000000.rev'
public and secret key created and signed.

pub   rsa4096 2022-08-05 [SC]
      0000000000000000000000000000000000000000
uid                      wjwdive (for github GPG key) <wjwdive@163.com>
sub   rsa4096 2022-08-05 [E]

查看GPG key

$ gpg --list-keys
gpg: checking the trustdb
gpg: marginals needed: 3  completes needed: 1  trust model: pgp
gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
/c/Users/Administrator/.gnupg/pubring.kbx
-----------------------------------------
pub   rsa4096 2022-08-05 [SC]
      0000000000000000000000000000000000000000
uid           [ultimate] wjwdive (for github GPG key) <wjwdive@163.com>
sub   rsa4096 2022-08-05 [E]

获取gpg key 公钥

$ gpg --armor --export 0000000000000000000000000000000000000000

github 里配置GPG key

IDEA 里配置,先重启IDEA

查看结果

标签:GPG,--,gpg,idea,github,git,key,wjwdive
来源: https://www.cnblogs.com/wjw-blog/p/16553534.html