I just started using GPG in Thunderbird 17 (via enigmail). Now I want to fill my private key database with all the keys of other people that use mail encryption as well. One way, other than asking people for their private keys directly, is to check a keyserver for their addresses, for some more contacts this is pretty lengthy task.

Is there any way to automatically poll a keyserver for all (or a subset of) addresses of the address book integrated in Thunderbird?


This is now built into Enigmail:

  1. Go to the Enigmail Key Management window
  2. Click Keyserver → Find keys for all contacts
  3. Go through some self-explanatory dialog boxes
  4. Select the keys you want to import
  5. Click OK

If you didn't select any keys in step 4, unfortunately the time spent searching for keys is wasted, since you get no warning that you're about to perform a no-op.


I've got a solution that will work on OS X, Linux, BSD and other *nix systems, but if you're on Windows you might be out of luck (or need to go to a little more effort).

Go into Thunderbird and open up the address book. There will probably be at least two sub-sections: personal addresses and collected addresses. There may be more. Highlight each of these sub-sections, go to tools and select export, name the file something appropriate and repeat the process for each sub-section of the address book. The export creates .ldif files containing all the details of every contact in plain text.

For this example I'm saying that I saved two files as /tmp/personal.ldif and /tmp/collected.ldif for the main address book sub-sections. Then it's time for a little work in a bash prompt:

cd /tmp/
grep "^mail: " personal.ldif > pmail.txt
grep "^mail: " collected.ldif > cmail.txt

Then open /tmp/pmail.txt and /tmp/cmail.txt in the text editor of your choice and fo a find/replace on "mail: " with nothing (i.e. ""). Then back to our little shell prompt to finish with:

for x in `cat pmail.txt` ; do
    gpg --recv-keys $x
    gpg --keyserver pgp.mit.edu --recv-keys $x
done ;

for x in `cat cmail.txt` ; do
    gpg --recv-keys $x
    gpg --keyserver pgp.mit.edu --recv-keys $x
done ;

Depending on how many email addresses are in your contact lists, that might take a while. Most of the responses will be failures, but you can just let it run in the background.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.