Skip to content

Instantly share code, notes, and snippets.

@edef1c
Last active August 18, 2019 05:03
Show Gist options
  • Save edef1c/eab037000a171b0e94b29fa587f4a844 to your computer and use it in GitHub Desktop.
Save edef1c/eab037000a171b0e94b29fa587f4a844 to your computer and use it in GitHub Desktop.
convert PGP authentication subkeys to OpenSSH authorized_keys format, discarding expiry information
#!/usr/bin/env bash
set -ue
if [ $# -ne 1 ]; then
echo "usage: $0 [exact PGP user ID]"
exit 255
fi
gpg --with-colons -k "=$1" |\
awk -F: '$1 == "sub" && $2 ~ /^[fu]$/ && $12 ~ /a/ { getline; print $10"!" }' |\
xargs -rL1 gpg --export-ssh-key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment