Ssh – Can emacs use gpg-agent in a terminal at all

emacsgpgsshterminal

I understand that there are problems with getting pinentry-curses to work with emacs (see some of the comments on http://emacswiki.org/emacs/EasyPG), and so using emacs in a terminal isn't compatible with gpg-agent because of this.

I can't use a graphical pinentry tool in this case as this is over an ssh connection to a remote machine.

However, is it possible to feed the gpg-agent the passphrase beforehand and then have emacs use this, but not to prompt for a passphrase if the agent doesn't already have this info?

What settings would allow this to work with notmuch.el and EasyPG?

Or, are there alternative methods of caching the passphrase which would achieve the same effect, but may have security problems (which is the reason gpg-agent exists in the first place)?

Best Answer

THIS! -> https://github.com/ecraven/pinentry-emacs

You'll have to do some wrenching, but using this thing worked for me. Put the script there into a directory in your PATH and then add the following entry to ~/.gnupg/gpg-agent.conf:

pinentry-program <path-to-pinentry-emacs>/pinentry-emacs

Then reload the agent:

$ echo RELOADAGENT | gpg-connect-agent

Works like a dream for me :)

Related Question