måndag 8 november 2010

More on getting PGP/ GPG keys into your keyring

One issue with PGP is getting the keys into your keyring. In a previous post, I described how to get the keys of all the people in your Address book into your ring. Of course, you don't want to keep all the people you sent an email to in your Address book, which means that not all of your potential PGP uses will be realised. What you need is the extract all the email addresses you ever saw, and then get the key for them. This is what we will do now.

 

First, get all the email addresses from your mailboxes using Perl (in the terminal):

cd ~/Library/Mail

for a in `find . -name "*.emlx"`;do perl -wne'while(/[\w\.]+@[\w\.]+\w+/g){print "$&\n"}' "$a";done > ~/Desktop/ad_all.txt

Then, extract only the unique email addresses:

cat ad_all.txt |sort |uniq > ad_uniq.txt

The, get GPG to fetch all the keys:

for a in `cat ad_uniq.txt`;do gpg --search-keys $a;done

This will take a while, but at the end of the run, you will have an updated GPG keyring with all of your email contacts keyrings in them.
Happy GPG-ing.

Inga kommentarer:

Skicka en kommentar