You can also use curl
to search for a key from a public keyserver if you know the key's ID:
curl -fsSL "https://keyserver.ubuntu.com/pks/lookup?op=get&options=mr&search=<key-id-here>" | gpg --import -
Note: you must prepend the key ID with 0x
.
Most public key servers allow you to truncate the key ID so you don't need to type the whole thing. For example, the following three examples will produce the exact same key:
curl -fsSL "https://keyserver.ubuntu.com/pks/lookup?op=get&options=mr&search=0x9454C19A66B920C83DDF696E07C8CCAFCE49F8C5" | gpg --import -
curl -fsSL "https://keyserver.ubuntu.com/pks/lookup?op=get&options=mr&search=0x07C8CCAFCE49F8C5" | gpg --import -
curl -fsSL "https://keyserver.ubuntu.com/pks/lookup?op=get&options=mr&search=0xCE49F8C5" | gpg --import -
Most of the key servers are synchronized too , so you don't necessarily need to stick with a single key server. You can see a list of other key servers and the information at the SKS Keyserver status page.
Explanations for the -fsSL
in the curl
command:
-f
, --fail
:
(HTTP) Fail silently (no output at all) on server errors.
-s
, --silent
:
Silent or quiet mode.
-S
, --show-error
:
When used with -s, --silent, it makes curl show an error message if it fails.
-L
, --location
:
(HTTP) If the server reports that the requested page has moved to a different location (indicated with a Location: header and a 3XX response code), this option will make curl redo the request on the new place.