5

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
    // , Do you think you could give an example of an error that you received? – Nathan Basanese Jun 24 '15 at 3:27
  • // , What does "they K coming from the manual on gpg." even mean, man? – Nathan Basanese Jun 24 '15 at 3:43
  • They -> the. Typo – Jason Basanese Jun 9 '18 at 6:08
  • // , By the way, for a first StackOverflow question, this is pretty damn good, Jason. – Nathan Basanese Dec 8 '18 at 22:39
9

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

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

  • 2
    This answer is very well done, but a little on the long side. – Jason Basanese Jun 24 '15 at 3:37
  • // , Like I said, I think this merits some explanation. However, I can add a quick TLDR at the top. Would that work? – Nathan Basanese Jun 24 '15 at 3:38
  • 1
    I think my answer is short and sweet and if it isn't thorough enough they can read yours. – Jason Basanese Jun 24 '15 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 '16 at 4:58
  • 1
    Just curious... why does everything you post start with // ,? – Mateen Ulhaq Feb 17 at 10:54
1

Turns out I was missing two dashes, the correct command is gpg --recv-keys "the key" in the command line.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.