CentOS 6 – gpg –gen-key Hangs at Gaining Enough Entropy

centos6gpg

Trying to generate a key for a server.

gpg --gen-key

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.

and it just hangs there.

There is another error:

can't connect to `/root/.gnupg/S.gpg-agent': No such file or directory

which seems to go away after:

gpg-agent –daemon
GPG_AGENT_INFO=/tmp/gpg-4c5hyT/S.gpg-agent:1397:1; export GPG_AGENT_INFO;

#GPG_AGENT_INFO=/tmp/gpg-4c5hyT/S.gpg-agent:1397:1; export GPG_AGENT_INFO;
gpg --gen-key
...

but again, it hangs at "…gain enough entropy".

There are no "++++++++++++++++++++++++++++++++++++++++++"'s which from forum posts looks like should be expected as the key is generated.

I have tried reinstalling the package, but seemingly everything depends on gpg.

I've read other people having problems with this on centos 6 too (whereas centos 5 works fine).

There is nothing remarkable in /var/log/*.

Any ideas on where to go from here?

Thanks.

Best Answer

When the gpg --gen-key command hangs like this, log in to another shell and perform the following command:

dd if=/dev/sda of=/dev/zero

(This command basically reads from your hard drive and discards the output, because writing to /dev/zero will do nothing.)

After a few seconds / minutes, the key generation command should complete.