Generating entropy on headless server while creating GPG key

Part of creating a GPG key pair is generating a certain amount of random bytes to get enough entropy. The command itself suggests the following:

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.

This can be a big problem on a headless server that has no keyboard or mouse. You can attempt to create a certain amount of disk activity, but I have not been able to generate enough to satisfy its requirements and the command fails.

I did stumble across this lovely command thought, that will satisfy it.

# rngd -r /dev/urandom

This command provides “true random number generation”. Straight from the Man page: This daemon feeds data from a random number generator to the kernel’s random number entropy pool, after first checking the data to ensure that it is properly random. Its super fast and creates enough entropy to create the GPG key.

If you don’t have the command on your system, look for package called rng-utils.

Leave a Reply

Your email address will not be published. Required fields are marked *