GNU Privacy Guard and Emacs

Mickey has an excellent new post on using GnuPG from within Emacs. This is really easy to set up and it’s pretty much transparent once you do. I set it up years ago and until I read Mickey’s post, I’d forgotten most of the details.

The first thing you need is to is enable the EasyPG library. Recent versions of Emacs have this built in but you still need to require and enable it:

(require 'epa-file)
(epa-file-enable)

After that any file with the .gpg extension will automatically be encrypted or decrypted when saving or opening it. The first time you use a particular password in an Emacs session, Emacs will prompt you for it but will remember it for the duration of the session. If you have any asymmetric keys on your keychain, Emacs will ask you which one to use. If you don’t have or choose one, Emacs will prompt you for a symmetric key.

That’s basically everything you need to know for encrypting/decrypting files but, of course, Mickey has more. He shows you how to set up an .authinfo file that contains the keys to certain services so that they can be accessed transparently from Emacs without the need to enter a password every time you use the service. That’s also easy but there are some fiddly details so I’ll let you read about them in Mickey’s post rather than regurgitating them here.

If you’re an Emacs user, you definitely want to read this post. Even if you don’t have any encrypted files, sooner or later you will need to protect some information and by setting up EasyPG now you won’t have to stop and figure things out when you do. All you’ll have to do is remember to add the .gpg to the file name and Emacs will take care of the rest.

This entry was posted in General and tagged . Bookmark the permalink.