Generating GPG Keys on CentOS 6

I recently ran into an issue where I was having problems creating a new set of GPG keys on a CentOS host that I was using.  Here is the process that eventually worked for me.

1. Run the following gpg-agent command:

gpg-agent --daemon --use-standard-socket --pinentry-program /usr/bin/pinentry-curses

2. Run the following rngd command to ensure there is enough entropy being generated:

sudo rngd -r /dev/urandom

3. Finally run the gpg command to generate the key:

gpg --gen-key

If you are running the gpg-agent as root you may run into other issue that prevent you from completing the process.  It is best to run as a non-root user.



  1. I was having a similar problem. The error I was getting is below:

    GnuPG needs to construct a user ID to identify your key.

    Real name: xxxxx
    Email address:
    You selected this USER-ID:

    Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? o
    You need a Passphrase to protect your secret key.

    gpg: cancelled by user
    gpg: Key generation canceled.

    Basically, it was cancelling without letting me enter a password.

    The problem turned out to be that I was su'ing from root into a user account. You need to log in directly as the user before running gpg --gen-key (don't use su).

    1. Thanks for the comment, I was going crazy with this!!!!
      It worked for me too!
      No more "su - USER" when creating keys.

    2. This comment has been removed by the author.

  2. thanks buddy, yes su - user is the problem,

    Direct login works for me too.

    Parag Gaur