Put it somewhere, make it executable, tell gpg
to use it as the
pinentry program.
One way to do this is adding the line
pinentry-program /path/to/where/you/put/pinentry-emacs
to the file ~/.gnupg/gpg-agent.conf
.
Make sure you restart gpg-agent and GPG_AGENT_INFO is set correctly inside Emacs!
If your Emacs hangs, you might have to C-g
, then you’ll get asked,
then you may have to restart the action. Your passphrase will be
cached for some time.
Add this to .emacs.d/init.el
or similar:
(defun pinentry-emacs (desc prompt ok error) (let ((str (read-passwd (concat (replace-regexp-in-string "%22" "\"" (replace-regexp-in-string "%0A" "\n" desc)) prompt ": ")))) str))
Sometimes your `.emacs` file has errors, or the emacs `pinentry` thing simply doesn’t work. In that case, this script falls back to using `lukspinentry` to get the password (which falls back onto gui/tty pinentry).
This is probably totally insecure, and your passphrase may be leaked! Use at your own risk!