
Problem
Cryptographic key creation (GnuPG, SSH, etc.) in virtual guests may be very slow because there is not enough entropy.
$ cat /proc/sys/kernel/random/entropy_avail 7
Solution
Add /dev/urandom from virtual host in virt-manager. Click on "Add Hardware".
Add "RNG" device.
This is what will be added to the qemu xml file in /etc/libvirt/qemu:
<domain type='kvm'> --- <devices> ... <rng model='virtio'> <backend model='random'>/dev/urandom</backend> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </rng> </devices> </domain>
In the virtual guest, install "rng-tools" (Ubuntu 18.04).
$ sudo apt-get install rng-tools
If something goes wrong, the rngd daemon will complain in /var/log/syslog.
Oct 13 22:48:07 guest rngd: read error Oct 13 22:48:07 guest rngd: message repeated 99 times: [ read error] Oct 13 22:48:07 guest rngd: No entropy sources working, exiting rngd
If rngd is working correctly, check entropy level again.
$ cat /proc/sys/kernel/random/entropy_avail 3162