automates listing of keyfiles

ADP-179_sops_manage_keys
LeeW 11 months ago
parent 3efade8643
commit f1e529f1ed

@ -2,27 +2,32 @@
set -euo pipefail set -euo pipefail
function fn_extract_fpr_uid_str(){ function fn_extract_fpr(){
gpgkeyfile=$1;shift; gpgkeyfile=$1;shift;
type=$1;shift; # fingerprint
# caveat: restrict to netgo.de email, use-case: # caveat: restrict to netgo.de email, use-case:
# uid ... <...@mehrwerk.net> # uid ... <...@mehrwerk.net>
# uid ... netgo.de> # uid ... <...@netgo.de>
# fingerprint
fpr="$(gpg --show-keys --list-options show-only-fpr-mbox "${gpgkeyfile}" | grep '@netgo.de' | awk "{print \$1}")" fpr="$(gpg --show-keys --list-options show-only-fpr-mbox "${gpgkeyfile}" | grep '@netgo.de' | awk "{print \$1}")"
echo "${fpr}"
}
function fn_extract_uid(){
gpgkeyfile=$1;shift;
# user id # user id
# caveat: restrict to netgo.de email, use-case:
# uid ... <...@mehrwerk.net>
# uid ... <...@netgo.de>
uid="$(gpg --show-keys --with-colons "${gpgkeyfile}" | awk -F':' '$1=="uid" {print $10}' | grep '@netgo.de')" uid="$(gpg --show-keys --with-colons "${gpgkeyfile}" | awk -F':' '$1=="uid" {print $10}' | grep '@netgo.de')"
echo "# ${fpr} | ${type} | ${uid}" echo "${uid}"
} }
echo "# Fingerprint | User Type | User ID" echo "# Fingerprint | User Type | User ID"
for gpgkeyfile in *automation*gpg.pub; do for gpgkeyfile in *automation*gpg.pub; do
u_type="autom" u_type="autom"
echo "$(fn_extract_fpr_uid_str "${gpgkeyfile}" "${u_type}")" echo "$(fn_extract_fpr "${gpgkeyfile}") | ${u_type} | $(fn_extract_uid "${gpgkeyfile}")"
done done
for gpgkeyfile in $(ls *gpg.pub | grep -v automation); do for gpgkeyfile in $(ls *gpg.pub | grep -v automation); do
u_type="human" u_type="human"
echo "$(fn_extract_fpr_uid_str "${gpgkeyfile}" "${u_type}")" echo "$(fn_extract_fpr "${gpgkeyfile}") | ${u_type} | $(fn_extract_uid "${gpgkeyfile}")"
done done

Loading…
Cancel
Save