Created
September 8, 2023 15:16
-
-
Save bynect/60cb1427db6c6053ef74a69409d821d3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# NOTE: This script exports only one uid | |
key_pattern= | |
remote_host= | |
remote_path=/var/www/html/.well-known/openpgpkey/hu/ | |
for item in $(gpg --list-secret-keys --with-colons ${key_pattern:- } \ | |
| awk -F: '($1 == "sec" && $2 == "u") { print $5}'); do | |
wkd_hash=$(gpg --with-wkd-hash --fingerprint "$item" \ | |
| grep -A 1 '^uid' \ | |
| tail -n 1 \ | |
| tr -d '[[:space:]]') | |
#this saves the files locally | |
#gpg --export --no-armor "$item" > "${wkd_hash%%@*}" | |
#echo "Exported key $item to file $( realpath "${wkd_hash%%@*}")" | |
#this sends them directly to the server | |
#gpg --no-armor --export "$item" | ssh "$remote_host" "cat > $remote_path/${wkd_hash%%@*}" | |
echo "Exported key $item to file $remote_path/${wkd_hash%%@*} on host '$remote_host'" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment