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

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,原创技术文章第一时间推送。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
禁止转载,如需转载请通过简信或评论联系作者。

推荐阅读更多精彩内容