美文网首页
CentOS下GPG密钥生成失败遇到的两个问题和解决方法

CentOS下GPG密钥生成失败遇到的两个问题和解决方法

作者: testerzhang | 来源:发表于2021-07-04 23:11 被阅读0次

1. 问题一

想生成GPG密钥,结果还没生成,就自动退出了。


$ gpg --gen-key

中间省略输入的内容,到了下面这句话,还没输入密钥就报错了

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
You need a Passphrase to protect your secret key.

gpg: cancelled by user
gpg: Key generation canceled.

解决方案:

  • 方法一:
$ script /dev/null
$ gpg2 --gen-key

然后就会弹出


image.png

可以输入密码了。

  • 方法二:

ssh 的时候直接对应的用户名登录,不要用su命令切换用户。

2. 问题二

image.png

卡在这里了,里面的英文是这样的:


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.

解决方案:

这时候在终端通过打字和移动鼠标很难满足。

解决办法是安装 rng-tools 这个工具,

  • 用root账号安装
# yum install rng-tools
  • 执行下面这个命令,生成密钥就能瞬间完成了。
# rngd -r /dev/urandom

Initalizing available sources

Initalizing entropy source Hardware RNG Device

Enabling RDSEED rng support

Initalizing entropy source Intel RDRAND Instruction RNG

Enabling JITTER rng support

Initalizing entropy source JITTER Entropy generator

这时候我们可以看到卡住的session已经自动生成session了。

     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: /home/testerzhang/.gnupg/trustdb.gpg: trustdb created
gpg: key xxxxx marked as ultimately trusted
public and secret key created and signed.

欢迎关注我的公众号testerzhang,原创技术文章第一时间推送。

相关文章

网友评论

      本文标题:CentOS下GPG密钥生成失败遇到的两个问题和解决方法

      本文链接:https://www.haomeiwen.com/subject/fgapultx.html