Collect PGP keys of all your contacts from keyserver
If you like to start encrypting your Emails you need partners who are also willing to set up the PGP encryption. And then you need to exchange the public keys. For that it’s handy to upload the own public key to a key-server. If you use Thunderbird with Enigmail that’s pretty easy. Go to OpenPGP > Key Management, right klick on your own key and select Upload Keys to Keyserver. Everybody else can now query the server and get your public key.
Wouldn’t it be great to run automatically trough your address book and search for everybody who has uploaded his key to a key-server? That’s quite easy with Thunderbird and Linux:
- export your address book
- open the Thunderbird address book
- select the address book you like to export
- go to Tools->Export
- select „Comma Separated“ as format in the bottom right corner
- choose addresses.csv as name and save the file in a directory you like e.g. /tmp
- configure GPG
- open the file ~/.gnupg/gpg.conf with a text editor
- add this line to the file:
of course you can use any other keyserver if you like
- save the file 🙂
- search for keys and import them
- open a console
- navigate to the directory you saved the file in e.g: cd /tmp
- run this command:
for add in `cat addresses.csv | cut -d“,“ -f5 | grep @`; do gpg -i –search-keys $add; done
This command will go through the file addresses.csv line by line, get the 5th element out of it and search if the server has a key for this email.
- If a key was found you will be asked to select it and if you like to import it.
- After a restart of Thunderbird you should see the newly imported keys in: OpenPGP > Key Management