Skip to content

Instantly share code, notes, and snippets.

@gasull
Forked from F30/gpg-list-ownertrust.py
Last active October 7, 2025 07:58
Show Gist options
  • Select an option

  • Save gasull/cc6c268ff4bcfb36fdf990bb20b27c02 to your computer and use it in GitHub Desktop.

Select an option

Save gasull/cc6c268ff4bcfb36fdf990bb20b27c02 to your computer and use it in GitHub Desktop.
List GPG Ownertrust
#!/usr/bin/env python3
import sys
import os
import gnupg
TRUST_LEVEL_MAP = {
'q': '???',
'n': 'Not',
'm': 'Marginal',
'f': 'Full',
'u': 'Ultimate'
}
def main():
gpg = gnupg.GPG()
gpg.encoding = 'utf-8'
keys = gpg.list_keys()
trust_keys = filter(lambda k: k['ownertrust'] != '-', keys)
for key in trust_keys:
trust_level = TRUST_LEVEL_MAP[key['ownertrust']]
print('{} {:<59} {}'.format(key['fingerprint'], key['uids'][0], trust_level))
return os.EX_OK
if __name__ == '__main__':
sys.exit(main())
@gasull
Copy link
Author

gasull commented Oct 7, 2025

Forked from @F30's original script. The long format of the key (fingerprint) is better since that's what is needed for later running gpg --edit-key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment