From 5fcba8c6868739b581a3f21fc0a31ed2555a270f Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Thu, 1 May 2025 13:02:42 +0200 Subject: [PATCH] chore(gnupg): just get the ascii value of keys with no headers nor footers --- knowledge base/gnupg.md | 19 +++++++++++-------- snippets/gnupg.fish | 6 ++++++ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/knowledge base/gnupg.md b/knowledge base/gnupg.md index 0be70c1..2e690c5 100644 --- a/knowledge base/gnupg.md +++ b/knowledge base/gnupg.md @@ -20,7 +20,7 @@ 1. [`sign_and_send_pubkey: signing failed for … from agent: agent refused operation`](#sign_and_send_pubkey-signing-failed-for--from-agent-agent-refused-operation) 1. [New configuration settings are ineffective](#new-configuration-settings-are-ineffective) 1. [Further readings](#further-readings) -1. [Sources](#sources) + 1. [Sources](#sources) ## TL;DR @@ -154,6 +154,13 @@ gpg --export-ssh-key 'ed25519_key' > ~'/.ssh/id_ed25519.pub' # Integrate with Pinentry. export GPG_TTY="$(tty)" + + +# Only get the base64 armored string in the key +# -e '/^-----/d' removes the header and footer +# -e '/^=/d' removes the base64 checksum at the bottom +# -e '/^$/d' removes empty lines +gpg --armor --export 'someone@example.org' | sed -e '/^-----/d' -e '/^=/d' -e '/^$/d' ``` ## Encryption @@ -518,9 +525,7 @@ gpg-connect-agent reloadagent '/bye' - [OpenPGP best practices] - [GNU/Linux crypto series] -## Sources - -All the references in the [further readings] section, plus the following: +### Sources - [Decrypt multiple openpgp files in a directory] - [ask redhat] @@ -536,7 +541,8 @@ All the references in the [further readings] section, plus the following: - [Stick with security: YubiKey, SSH, GnuPG, macOS] @@ -544,9 +550,6 @@ All the references in the [further readings] section, plus the following: [modify .gnupg home directories]: https://www.gnupg.org/documentation/manuals/gnupg/gpgconf.html [unattended key generation]: https://www.gnupg.org/documentation/manuals/gnupg/Unattended-GPG-key-generation.html - -[further readings]: #further-readings - [archlinux's gnupg wiki page]: https://wiki.archlinux.org/title/GnuPG [ask redhat]: https://access.redhat.com/solutions/2115511 diff --git a/snippets/gnupg.fish b/snippets/gnupg.fish index 7cfb8ae..ed3436f 100644 --- a/snippets/gnupg.fish +++ b/snippets/gnupg.fish @@ -34,3 +34,9 @@ gpgconf --launch gpg-agent find . -type f -not -name '*.gpg' \ -path '*/values.*.y*ml' -path '*/secrets/*.*' \ -exec gpg --batch --encrypt-files --yes -r "0123...CDEF" "{}" ';' + +# Only get the base64 armored string in the key +# -e '/^-----/d' removes the header and footer +# -e '/^=/d' removes the base64 checksum at the bottom +# -e '/^$/d' removes empty lines +gpg --armor --export 'someone@example.org' | sed -e '/^-----/d' -e '/^=/d' -e '/^$/d'