How to list trust level of OpenPGP public keys in GnuPG?

Solution 1:

You can export all configured owner trust through gpg --export-ownertrust. The output is of the form

FINGERPRINT:TRUST:

For my own key (which has ultimate trust on my machine), there is following line included:

0D69E11F12BDBA077B3726AB4E1F799AA4FF2279:6:

It seems the trust level is corresponds to the number entered in the trust edit command plus one:

1 = I don't know or won't say (export: 2)
2 = I do NOT trust            (export: 3)
3 = I trust marginally        (export: 4)
4 = I trust fully             (export: 5)
5 = I trust ultimately        (export: 6)

The output of this command can also be imported again through gpg --import-ownertrust.

Solution 2:

I wrote a small script to do this more easily: gpg-list-ownertrust.py

It is based on the python-gnupg library, which fortunately makes access to the ownertrust level very convenient.