16

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]

1
  • // , What does "they K coming from the manual on gpg." even mean, man? Jun 24, 2015 at 3:43

2 Answers 2

19

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 key server.

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

The key server 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) whose fingerprint is 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 -).

--recv-keys 

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

7CE8FC69BE118222

This tells GnuPG which key to import.

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

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

--recv-keys key IDs

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

3
  • 3
    This answer is very well done, but a little on the long side. Jun 24, 2015 at 3:37
  • 1
    I think my answer is short and sweet and if it isn't thorough enough they can read yours. Jun 24, 2015 at 3:40
  • 1
    I think this answer deserves to be marked correct; comprehensive answers are good, if the explanation is needed. @Jens-Erat would you improve this answer by giving the simple “do this” answer at the top before the long explanation?
    – bignose
    Nov 1, 2016 at 4:58
3

Turns out I was missing two dashes, the correct command is gpg --recv-keys $KEY (where $KEY is replaced by the key) in the command line.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .