Gnupg: How to exchange keys with key server

gnupgopenpgp

How do you exchange keys with via key server?

Worked example would be great with send and find+retrieve.

I know gpg --send-keys is the command but how do you find the keyid (tried all output from –--list-keys). --keyserver keys.gpugp.net works with --send-keys but not with --search-keys (says bad uri). Which keys should I publish? What key server to publish to. Despite being a pretty simple program, the gnugp docs are terrible (broken links, missing info).

Best Answer

What Went Wrong

You're dealing with two problems:

  1. gpg --search-keys searches keyservers, not locally. Use gpg --list-keys instead.
  2. GnuPGs keyserver domain is keys.gnupg.net, not keys.gpugp.net (typo). Additionally, you have to prefix a protocol, hkp:// is supported by most keyservers.

Relevant Commands for Exchanging Keys

  • gpg --send-keys [keyid]: Send key id to a keyserver
  • gpg --recv-keys [keyid]: Fetch key id from a keyserver
  • gpg --search-keys [needle]: Search for keys on a keyserver that contain "needle", eg. in a UID
  • gpg --list-keys [needle]: List all local keys that contain "needle", eg. in a UID

To select another keyserver than the default one configured, use --keyserver [URI]. Make sure to use a complete and valid URI like hkp://pool.sks-keyservers.net, or hkp://keys.gnupg.net (which actually refers to the SKS keyserver pool ourdays).