2013/09/13

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.

Nate

6 comments:

  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:
    Comment:
    You selected this USER-ID:
    "xxxxx"

    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).

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

      Delete
    2. This comment has been removed by the author.

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

    Direct login works for me too.

    Regards,
    Parag Gaur

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete