openpgp.org has a facility for https. Just imported a few keys by their fingerprints. The path is predictable you just need to replace ${KEY_FINGERPRINT} with the fingerprint of the key you want to import. Which of course must be already uploaded to https://keys.openpgp.org:
curl --sSL https://keys.openpgp.org/vks/v1/by-fingerprint/${KEY_FINGERPRINT} | \
gpg --import
The Ubuntu keyserver also has an HTTP(S) API by which one can fetch keys in ASCII format:
curl -sSL https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x${KEY_FINGERPRINT} | \
gpg --import
Note the | gpg --import pipe, which is used to import the key data into the GnuPG keyring.
Automating GPG/PGP Key Importation via HTTPS:
Since the path https://keys.openpgp.org is predictable and only varies by the fingerprint of keys stored on the server, we can automate importation of a list of keys identified by their fingerprints. Below is tested and know to work correctly
To adapt script to your own use, simply replace my (3) specimen key fingerprints with fingerprints of keys you want to import and of course set the variable PATHSCRIPTS to your desired path:
#!/bin/bash
PATHSCRIPTS='/home/pi'
# Create text file using a Here-Doc containing Key Fingerprints of keys to import into keyring:
cat <<EOF> $PATHSCRIPTS/Key-fingerprints-list.txt
AEB042FFD73BAA7545EDA021343A2DF613C5E7F8
7AFAF20259E69236E43EEF521F45D0F6E89F27A6
704FCD2556C40AF8F2FBD8E2E5A1DE67F98FA66F
EOF
# Read the text file we created into an array
readarray arrayKeyFingerprints < $PATHSCRIPTS/Key-fingerprints-list.txt
# Loop through the array adding each key in turn by its fingerprint from keys.openpgp.org:
for i in ${arrayKeyFingerprints[@]}; do
curl https://keys.openpgp.org/vks/v1/by-fingerprint/$i | gpg --import
done
Results of the above script- which was saved as test.sh and ran on a Raspberry Pi- are shown below:
pi@pi4-ap1:~ $ ./test.sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3212 100 3212 0 0 7629 0 --:--:-- --:--:-- --:--:-- 7629
gpg: /home/pi/.gnupg/trustdb.gpg: trustdb created
gpg: key 343A2DF613C5E7F8: public key "Terrence Houlahan (I'm the former NYPD cop living in the UK. This is my only *personal* key. Trust no others.) <[email protected]>" imported
gpg: Total number processed: 1
gpg: imported: 1
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3220 100 3220 0 0 18720 0 --:--:-- --:--:-- --:--:-- 18612
gpg: key 1F45D0F6E89F27A6: public key "Terrence Houlahan (Terrence Houlahan Linux & Network Engineer) <[email protected]>" imported
gpg: Total number processed: 1
gpg: imported: 1
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3252 100 3252 0 0 19473 0 --:--:-- --:--:-- --:--:-- 19473
gpg: key E5A1DE67F98FA66F: public key "Terrence Houlahan (Open-IPcamera Project Developer Key Terrence Houlahan) <[email protected]>" imported
gpg: Total number processed: 1
gpg: imported: 1
We do a key list and there are our (3) imported keys:
pi@pi4-ap1:~ $ gpg --list-keys
/home/pi/.gnupg/pubring.kbx
---------------------------
pub rsa4096 2011-03-13 [SC]
AEB042FFD73BAA7545EDA021343A2DF613C5E7F8
uid [ unknown] Terrence Houlahan (I'm the former NYPD cop living in the UK. This is my only *personal* key. Trust no others.) <[email protected]>
sub rsa4096 2011-03-13 [E]
pub rsa4096 2019-02-06 [SC] [expires: 2029-01-31]
7AFAF20259E69236E43EEF521F45D0F6E89F27A6
uid [ unknown] Terrence Houlahan (Terrence Houlahan Linux & Network Engineer) <[email protected]>
sub rsa4096 2019-02-06 [E] [expires: 2029-01-31]
pub rsa4096 2019-02-06 [SC] [expires: ????-??-??]
704FCD2556C40AF8F2FBD8E2E5A1DE67F98FA66F
uid [ unknown] Terrence Houlahan (Open-IPcamera Project Developer Key Terrence Houlahan) <[email protected]>
sub rsa4096 2019-02-06 [E] [expires: ????-??-??]