gpg --gen-key: Not enough random bytes available

Not enough random bytes available. Please do some other work to give the OS a chance to collect more entropy! (Need ### more bytes)
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.

  • 情况分析

    运行此命令的设备是 AWS 上申请的一台EC2虚拟机,安装的是 Ubuntu 16.04.2 LTS,使用SSH客户端远程管理服务器。
    根据提示,可采取一些动作(action)生成更多的随机字节(random bytes),如敲击键盘、移动鼠标、使用硬盘等等。因 SSH 链接只能使用键盘,所以采取敲击键盘和下载大文件两个方法,但都不奏效,gpg 工具仍不能返回任何结果。

  • 解决办法

    stackoverflow 上看到一篇 closed 状态帖子,找到了解决问题的办法

    • 可用

      sudo apt-get install rng-tools

      I have found a remarkable speed increase by using rng-tools in the universe repository, which can be installed with Synaptic or another GUI package manager, or via the command-line

    • 未试

      sudo find / -type f | xargs grep somerandomstring > /dev/null

      Executing the following command in the background works for me

  • 参考链接

    [1] Amason webservices homepage
    [2] A stackoverflow post