Receiving a key from a keyserver in gnupg


How does one receive a key from a keyserver in gnupg?
I have tried typing $ gnupg rec-keys "the key"
Error given was,
usage: gpg [options] [filename]
I have also entered just rec-keys "the key"
Error given, recv-keys: command not found
in addition to gpg K recv-keys "the key" the K coming from the manual on gpg.
Error given, usage: gpg [options] [filename]

Best Answer

// , GnuPG (used by the gpg command) is just a client made for use of the OpenPGP system.

OpenPGP has a lot of parts. One of those parts, the local client, is right there, on your hardware: GnuPG. Another part, though, is the keyserver.

GnuPG is going to access a keyserver to obtain a key.

The keyserver will look up the key by its "fingerprint", that is, a special name designed to be verifiably unique to that key.
Here follows an example command to use the GnuPG package's gpg command to receive a key (--recv-keys) with the fingerprint 7CE8FC69BE118222:

$ gpg --recv-keys 7CE8FC69BE118222

Let me break this down, piece by piece:

$ gpg

This is the basic command, on most popular Linux systems available, to run the GnuPG program ("option flags" like this are used to modify Linux commands, and the "option flags" usually start with -- or -).


This "option flag" tells GnuPG to import keys from a keyserver.


This tells GnuPG which key to import.

Assuming that you're on a Debian system, a keyserver need not be specified, but adding --keyserver will do the trick.

From the info page on GnuPG (the gpg info page can be accessed by running the command info gpg):

--recv-keyskey IDs

Import the keys with the given key IDs from a keyserver. Option --keyserver must be used to give the name of this keyserver.