Enabling Virtio RNG Stay organized with collections Save and categorize content based on your preferences.
Virtio RNG is a paravirtualized random number generator. Virtio RNG providesrandom numbers from an entropy pool generated by the host machine of yourvirtual machine (VM) instance. The entropy pool collects random bits ofinformation from the system and uses that information to generate truly randomnumbers, which you can use for sensitive information, such as SSH keys or uniqueIDs.
Before you begin
- If you haven't already, set upauthentication. Authentication verifies your identity for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:
Install the Google Cloud CLI. After installation,initialize the Google Cloud CLI by running the following command:
gcloudinit
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update.- Set a default region and zone.
Limitations
- Virtio RNG is not available for Windows images.
- By default, Compute Engine VMs use Virtio RNG instead of a daemonto refill the guest entropy pool. If you prefer to usean entropy gathering daemon instead of or along with Virtio RNG, youmust install one. For an example of an entropy gathering daemon, see the
rng-toolsdocumentation.
Checking if Virtio RNG is enabled
Note: Virtio RNG comes pre-enabled on all Linux VMs.You can check whether Virtio RNG is enabled on your VM by running the followingcommand:
lsmod | grep rng
When Virtio RNG is enabled, your output is similar to the following:
virtio_rng 16384 0rng_core 16384 2 virtio_rngvirtio_ring 28672 4 virtio_rng,virtio_scsi,virtio_pci,virtio_netvirtio 16384 4 virtio_rng,virtio_scsi,virtio_pci,virtio_net
Testing Virtio RNG
You can test Virtio RNG by using the/dev/random device.
Connect to the VM by using SSH. For example, you can use thegcloud CLI to connect:
gcloud compute sshVM_NAME
Replace
VM_NAMEwith the name of your VM.Install
rng-tools:CentOS
Use the following command to install
rng-tools:sudo yum install rng-tools
Debian
Use the following command to install
rng-tools:sudo apt install rng-tools
Fedora CoreOS
Use the following command to install
rng-tools:sudo yum install rng-tools
RHEL
Use the following command to install
rng-tools:sudo yum install rng-tools
SLES
Use the following command to install
rng-tools:sudo zypper install rng-tools
Ubuntu LTS
Use the following command to install
rng-tools:sudo apt install rng-tools
Some Ubuntu images return a
Package 'rng-tools' has no installationcandidateerror. If you receive this error, run the following commands:sudo apt updatesudo apt install rng-tools
On the VM, run the
rngtestcommand:cat /dev/random | rngtest -c 1000
If Virtio RNG isn't enabled, the command doesn't return anything. Ifit is enabled, you receive a response similar to the following:
rngtest 2-unofficial-mt.14..rngtest: starting FIPS tests...rngtest: bits received from input: 20000032rngtest: FIPS 140-2 successes: 1000rngtest: FIPS 140-2 failures: 0rngtest: FIPS 140-2(2001-10-10) Monobit: 0rngtest: FIPS 140-2(2001-10-10) Poker: 0rngtest: FIPS 140-2(2001-10-10) Runs: 0rngtest: FIPS 140-2(2001-10-10) Long run: 0rngtest: FIPS 140-2(2001-10-10) Continuous run: 0rngtest: input channel speed: (min=4.801; avg=7.318; max=7.839)Mibits/srngtest: FIPS tests speed: (min=39.005; avg=69.557; max=72.523)Mibits/srngtest: Program run time: 2880954 microseconds
What's next
- Learn more aboutVirtio RNG
- Learn more about
/dev/random - ViewOperating system details to learn moreabout the images available on Compute Engine
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-18 UTC.