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]
3 Answers
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 IDsImport the keys with the given key IDs from a keyserver. Option
--keyserver
must be used to give the name of this keyserver.
-
3This answer is very well done, but a little on the long side. Commented Jun 24, 2015 at 3:37
-
1I think my answer is short and sweet and if it isn't thorough enough they can read yours. Commented Jun 24, 2015 at 3:40
-
1I 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?– bignoseCommented Nov 1, 2016 at 4:58
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.
-
// , Linux has a concept of
flags
. It's the Linux way to make terminal commands more complicated. Check it out: unix.stackexchange.com/q/285575/48498 Commented Jun 4, 2018 at 18:26
To receive a key from a keyserver using gnupg you can:
gpg --keyserver hkps://keys.openpgp.org \
--recv-keys DEFF32913C2F7C41ADF087782D1B5748A391B4E0
Uploading instead? See Where to upload PGP public key? Are KeyServers still surviving?