September 13, 2025

Retrieve a GPG key for a given email address from the cli

First run:

$ echo "keyserver hkps://keys.openpgp.org" > .gnupg/gpg.conf

Then to retrieve the GPG key pair with the email address of someone run:

$ gpg --auto-key-locate keyserver --locate-keys email@example.com

Add that command to ~/bin/ as a script:

$ gpg --auto-key-locate keyserver --locate-keys "$@"

Alias that script to:

alias fetch='fetch_gpg_key.sh'

Then you can retrieve a GPG key with:

$ fetch email@example.com

If a key is available, it will be added to your GPG keyring.

Next step would be to run that script automatically from Mutt if the GPG key of the email address isn’t in the keyring and is found on a server.

Source: https://keys.openpgp.org/about/usage


personal computing command-line interface (cli) gnu linux trisquel shell literacy office applications wiki gpg

No affiliate links, no analytics, no tracking, no cookies. This work © 2016-2025 by yctct is licensed under CC BY-SA 4.0 .   about me   contact me   all entries & tags   FAQ   GPG public key

GPG fingerprint: 2E0F FB60 7FEF 11D0 FB45 4DDC E979 E52A 7036 7A88