Generating entropy in a containerised environment Print

  • openvz, container
  • 0

Running commands like gpg --gen-key requires a good source of entropy, and in containerised environments like OpenVZ, obtaining sufficient entropy can be challenging due to restricted permissions.

In these cases we suggest using one of the following options.

1. Use External Entropy Sources

From another machine with good entropy, you can feed entropy into your container from that machine.

Method:

a) On the Host or Another Machine with High Entropy:

cat /dev/random | base64 | ssh root@[container-ip] "base64 -d > /dev/random"

b) On the container:

#Check the entropy level
cat /proc/sys/kernel/random/entropy_avail

# Run gpg --gen-key
gpg --gen-key

 

2. Manual Entropy Gathering

You can manually generate entropy by performing actions that create system activity (such as copying files, running commands, etc.) in parallel while running the key generation process.

# In one terminal, perform continuous system activity
find / -type f | xargs cat > /dev/null

In another terminal, run gpg --gen-key
gpg --gen-key

 


Was this answer helpful?

« Back