GPG error "Not enough random bytes available. Please do some other work to give the OS a chance to collect more"

UbuntuGnupg

Ubuntu Problem Overview


I am using:

 gpg --gen-key

Is there a better way to create a PGP key? What does this program want? A fully slammed server?

> Not enough random bytes available. Please do some other work to give the OS a chance to collect more

Ubuntu Solutions


Solution 1 - Ubuntu

Depending on your system hardware, you might have more reliable success using a bridge between the hardware TRNG (True random number generator) and the kernel entropy pool.

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 apt-get install rng-tools

Solution 2 - Ubuntu

Executing the following command in the background works for me:

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

Solution 3 - Ubuntu

You can move your mouse around, browse the internet, play a game, leave your computer on overnight. There are many many ways to generate random bytes. You don't need to babysit the gpg process.

EDIT: I should clarify: you don't need to pay attention or even type into the terminal that gpg is running in. (And it's a really bad idea to type into that terminal anyway.)

If you're on a remote server, and cannot otherwise generate work, you can try this: http://packages.debian.org/squeeze/stress. Use caution, though.

Solution 4 - Ubuntu

I found that just moving the program to the background worked even over an ssh interface:

  1. move the task to the background (Ctrl+z)
  2. perform a few short tasks (cd ~ && ./my-time-waster.sh)
  3. move the task to the foreground (fg)
  4. wait a minute or two

I'm using CentOS5 and CentOS6.

Solution 5 - Ubuntu

Try using rngd, but without the -r /dev/random you will often see people advise (which will lead to insecure GPG keys). On my machine, just installing rngd installs a daemon which fills up my entropy quickly, and securely.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTampaView Question on Stackoverflow
Solution 1 - UbuntukylehuffView Answer on Stackoverflow
Solution 2 - UbuntumunyengmView Answer on Stackoverflow
Solution 3 - UbuntuInfiltratorView Answer on Stackoverflow
Solution 4 - UbuntuJellicleCatView Answer on Stackoverflow
Solution 5 - UbuntuChris JeffersonView Answer on Stackoverflow