yum install rng-tools #先安装一个密钥生成工具
rngd -r /dev/urandom
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 -help #查看帮助文件及版本信息
gpg --gen-key
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)
Your selection?
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048)
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 expires at Fri 23 Sep 2022 04:45:58 PM CST
Is this correct? (y/N) y
Key expires at Fri 23 Sep 2022 04:27:39 PM CST
Is this correct? (y/N)
Real name: jackchen
Email address: sj***@qq.com
Comment: test
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? o
gpg -c h.txt #出现下面输入密码对话框,输入并确认自己的密码即可。
ls -lh #此时会多出一个密码后的文件 h.txt.gpg,这里的文件我们就可以发给对方了,对方在接受到文件后即可使用设置的密码进行解密
gpg h.txt.gpg
ls -lh #可看到解密后的文件