运行gpg --gen-key生成key时出现卡住的问题

背景

  在搭建Ubuntu16.04的本地apt源时,需要运行“gpg --gen-key”命令,但是在执行该命令时,出现了:“Not enough random bytes available. Please do some other work to give the OS a chance to collect more ”的提示,而且一直卡住。

分析

  更详细的提示,参加:

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.

  根据提示,该命令生成key时,需要kernel为该程序生成足够多的随机数,因此,我们只需要为kernel生成随机数即可。

解决方法:

  安装rng-tools工具,该工具可以像指定文件生成随机数。这里,我们不需要退出原正在执行gpg --gen-key命令的console,新建一个终端,执行如下命令。命令执行完成后,原来卡住的界面就恢复运行了。

$ apt-get install rng-tools
$ rng -r /dev/urandom
原文地址:https://www.cnblogs.com/styshoo/p/6415939.html