1、在centos7中使用gpg创建RSA非对称密钥对
```powershell
[19:49:25 root@igcllq\ [ ~]#gpg --gen-key
gpg (GnuPG) 2.0.22; Copyright (C) 2013 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.
请选择您要使用的密钥种类:
(1) RSA and RSA (default)
(2) DSA and Elgamal
(3) DSA (仅用于签名)
(4) RSA (仅用于签名)
您的选择? 1
RSA 密钥长度应在 1024 位与 4096 位之间。
您想要用多大的密钥尺寸?(2048)1024
您所要求的密钥尺寸是 1024 位
请设定这把密钥的有效期限。
0 = 密钥永不过期
<n> = 密钥在 n 天后过期
<n>w = 密钥在 n 周后过期
<n>m = 密钥在 n 月后过期
<n>y = 密钥在 n 年后过期
密钥的有效期限是?(0) 0
密钥永远不会过期
以上正确吗?(y/n)y
You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
"Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>"
真实姓名:centos7
电子邮件地址:
注释:
2、将CentOS7导出的公钥,拷贝到CentOS8中,在CentOS8中使用CentOS7的公钥加密一个文件
查看生成的公钥
查看centos7生成的公钥
[19:50:56 root@igcllq\ [ ~]#gpg --list-keys
/root/.gnupg/pubring.gpg
把centos7上的公钥到到centos7.pubkeyzhong,发送到centos8上
[20:01:04 root@igcllq\ [ ~]#gpg -a --export -o centos7.pubkey
[19:58:50 root@igcllq\ [ ~]#scp centos7.pubkey 10.0.0.8:/root
root@10.0.0.8's password:
centos7.pubkey 100% 1858 1.3MB/s 00:00
centos8加密也需要密钥对
[root@CentOS8 ~]# gpg --gen-key
gpg (GnuPG) 2.2.9; Copyright (C) 2018 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.
You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
"Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>"
真实姓名:centos8
电子邮件地址:
您选定了这个用户标识:
“centos8”
Change