Andy Regan Ramblings of an Irish Sysadmin

27Jul/100

Lack of Entropy on Virtual Machine

If you are generating GPG keys on a virtual machine, you may encounter the following error.

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

Operating systems generate randomness based on hardware input. This randomness is collected for use in applications which require random data (such as cryptographic applications). However, a virtual OS does not have the same level of access to real hardware. As a result, the usual source of randomness expected by the operating system is not available. The measure of randomness currently available (entropy) can be viewed by running $ cat /proc/sys/kernel/random/entropy_avail .

If the entropy pool drains, /dev/random will block until additional entropy is collected. One solution is to use /dev/urandom as a source. This will not block, but will produce lower quality randomness. You can use /dev/urandom by installing rng-tools and adding the following to /etc/default/rng-tools. Save and then restart rng-tools.

HRNGDEVICE=/dev/urandom

Unfortunately, using /dev/urandom is not suitable for my security requirements. A better solution would be to use a hardware entropy generator as described in Andy Smith's excellent post .

As a short-term work-around, I decided to generate keys on a physical host with a good quality source of randomness and then import them on the remote host.

Filed under: Linux Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.