Fw: Exporting only trusted public keys
Maxim Britov <[email protected]> Thu, 21 Aug 2003 10:10:13 +0300
| Newsgroups | gmane.comp.security.pgp-n-gpg |
|---|---|
| Message-ID | <[email protected]> |
Кому-нибудь может очень пригодиться. Begin forwarded message: Date: Wed, 20 Aug 2003 21:40:16 -0400 From: David Shaw <dshaw-wh+mT2OhP0WF0gnf/[email protected]> To: GnuPG Users <[email protected]> Subject: Re: Exporting only trusted public keys On Wed, Aug 20, 2003 at 07:02:01PM -0400, Jeff McAdams wrote: > Also Sprach Neil Williams Content-Description: signed data > >On Wednesday 20 Aug 2003 10:33 pm, Neil Williams wrote: > >> With a keyring of >400 now, I know that I have approx 150 completely > >> redundant keys in the keyring - usually keys imported to validate > >> one-off emails or wrongly imported to try and form a web of trust. > >> These show up in KGPG as Trust:? > > >After a little thought, I came up with these commands: > >1. Retrieve details of only trusted keys: > >$ gpg --list-keys --with-colons | grep "pub:[u|f|m]:" > trusted.txt > > > >2. use perl to obtain the 16character keyid form: > >$ cat trusted.txt | perl -e 'while (<>) { $_ =~ /([A-Z0-9]{16})/;print "$1 "}' > >> export.txt > > > >3. Export each keyid into one keyring. > >$ cat export.txt | perl -e 'while(<>){`gpg -a --output trusted.gpg --export > >$_`;}' > > Just an attempt to help out... > > The above, essentially munged into a single pipeline. > > gpg --list-keys --with-colons | grep "^pub:[u|f|m]:" | cut -f5 -d":" | \ > xargs gpg -a --export | gpg --import --nodefault-keyring --keyring \ > /tmp/foo.gpg > > Replace "/tmp/foo.gpg" with the destination keyring, of course. Excellent! Here's a very minor optimization of that command line which skips the call to xargs and avoids converting to and from ASCII: gpg --export `gpg --list-keys --fixed-list-mode --with-colons | \ grep "^pub:[u|f|m]:" | cut -f5 -d":"` | gpg --import \ --no-default-keyring --keyring /tmp/foo.gpg If you want to just delete any keys that aren't part of your web of trust without making a whole new keyring first, you can do: gpg --batch --yes --delete-key `gpg --list-keys --fixed-list-mode \ --with-colons | grep "^pub" | grep -v "^pub:[u|f|m]:" | cut -f5 -d":"` David -- MaxBritov GnuPG KeyID 0x4580A6D66F3DB1FB Keyserver hkp://keyserver.kjsl.com Fingerprint: 4059 B5C5 8985 5A47 8F5A 8623 4580 A6D6 6F3D B1FB
00000003.mimetmp
(application/pgp-signature, 269 B) - not displayed
signature.asc
(application/pgp-signature, 484 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3rc1 (GNU/Linux) iQEVAwUBP0RwW1JphUrYR8fHAQI8mAf/eKkgmjeWct3pPAErIhSsWzpaMpWXskr/ 3HMsOKjTqVvhWlouRIe0hsrb6KkdnRtzRNu2crJ+olQiwcTLbXkUMjs6OfddyJox +D9GWvJB9BZlI8Ju9v3h0pmQAv8HI6+75kik+XCDbk4KBfLV60xgbNGVzATAGp/G eOpGMMQypFzyX2dJYSUTJyqgTseJcdPh51gRB0bqHZCgeC/GlNkREImIEriJFx1+ h1C8rF0bf4H0uhwquMkL7YEHXAMUUvT7wHiJj9SvCjPpQfC3UxuzcpNnk1RjvSBh yM7VZ99/a3wrgXjp02+1ZvuVT+Au3hbNG850RlUtwG99cCF4tEXFqw== =x28z -----END PGP SIGNATURE-----