Skip to content

Instantly share code, notes, and snippets.

@yushijinhun
Last active February 26, 2020 07:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yushijinhun/4a47c89c009e2783a9c8ed55d09518c2 to your computer and use it in GitHub Desktop.
Save yushijinhun/4a47c89c009e2783a9c8ed55d09518c2 to your computer and use it in GitHub Desktop.
GPG Cheatsheet
  • Retrieve keys of those who trust you

    gpg --recv-keys $(gpg --with-colons --no-expensive-trust-checks --list-sigs <your_id> | grep 'User ID not found' | cut -d: -f5 | sort | uniq | xargs)`
  • List all keys signed by a given key

    # params: long_keyid
    # 
    function gpg_list_keys_signed_by() {
      keyid=${1:-'0000000000000000'}
      gpg --with-colons --fingerprint --list-sigs |
      while read line; do
        packettype="$(echo "${line}" | cut -d':' -f1)"
        case $packettype in
          fpr)
            fingerprint="$(echo "${line}" | cut -d':' -f10)"
            ;;
          sig)
            issuedby="$(echo "${line}" | cut -d':' -f5)"
            if [ "x${issuedby}" = "x${keyid}" ]; then
              echo "${fingerprint}"
            fi
            ;;
        esac
      done |
      uniq
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment