I'm having a hard time setting up pinentry for Emacs to work with authentication (lets say for github). Using GPG and pinentry for signing commits already works. I use magit inside emacs for version control, and everytime I commit something pinentry pops up in the minibuffer, I enter my password and the commit is signed. All good.
However I also use GPG for authentication. I setup and authentication subkey with GPG and setup SSH to use it. If I do this from the tty it works as well. Just not from inside Emacs. The problem has something to do with the $GPG_TTY env var. If I try to push something to GH, pinentry in the minibuffer doesn't pop up. Instead it waits and eventually says I have no permission.
I should mention that I use emacs, more specifially EXWM as my window manager. If I then exit out of emacs I see the pinentry-encurses dialog in my TTY. If I have another terminal open in emacs while pushing it will open the pinentry-ncurses dialog in that terminal instead of popping up pinentry.el in the minibuffer.
I've been googling and trying out different approaches for days now with no luck.
~/.gnupg/gpg-agent.conf:
allow-emacs-pinentry
allow-loopback-pinentry
default-cache-ttl 600
max-cache-ttl 7200
enable-ssh-support
~/.gnupg/gpg.conf:
use-agent
~/.bash_profile:
# GPG related
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
export GPG_TTY=$(tty)
#gpgconf --launch gpg-agent
My pinentry config in emacs:
;; Enable loopback so that pinentry will pop up in emacs
(setq epa-pinentry-mode 'loopback)
(pinentry-start)
;; Update the TTY for gpg-agent
;(setenv "GPG_TTY" "/dev/pts/0")
(shell-command "gpgconf --launch-agent")
(shell-command "gpg-connect-agent updatestartuptty /bye >/dev/null")
I tried setting the $GPG_TTY manually inside emacs as you can see with no luck. It's baffling to me that it will just work for signing commits but not authentication.