Skip to content

How do I authenticate gpg within Emacs ? #4647

Closed
@Benjamin-Philip

Description

@Benjamin-Philip

The Issue

I am unable to get pinentry within emacs working. Whenever I have to authenticate (to commit), I get the following error (except when the password is cached):

128 git --no-pager --literal-pathspecs -c core.preloadindex\=true -c log.showSignature\=false -c color.ui\=false -c color.diff\=false commit --
17:22:50.743823 git.c:442               trace: built-in: git commit --
hint: Waiting for your editor to close the file...
17:22:50.764559 run-command.c:663       trace: run_command: '/usr/bin/emacsclient.emacs --socket-name=/tmp/emacs1000/server' /mnt/d/Benjamin/Documents/themes/textbook/.git/COMMIT_EDITMSG
Waiting for Emacs...
17:23:43.455558 run-command.c:663       trace: run_command: gpg2 --status-fd=2 -bsau <my gpg key>
error: gpg failed to sign the data
fatal: failed to write commit object

And nothing happens when I try to open a .gpg file (No prompt for password to decrypt).

Expected behavior

pinentry to just work after following documentation

What have I tried ?

As per the ELPA documentation, I have added allow-emacs-pinentry to my ~/.gnupg/gpg-agent.conf. I have also installed pinentry.el and have started the pinentry-server.

Here is my gpg-agent.conf:

# Keyboard control
no-grab

# PIN entry program
allow-emacs-pinentry
allow-loopback-pinentry
enable-ssh-support

This is my ~/.doom.d/packages.el (I have a week old install):

(package! pinentry)

And this is my ~/.doom.d/config.el:

(use-package! pinentry
        :init (setq epa-pinentry-mode `loopback)
               (pinentry-start))

System details

gnupg2 :

ben@frodo:~$ gpg2 --version
gpg (GnuPG) 2.2.20
libgcrypt 1.8.5
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: /home/ben/.gnupg
Supported algorithms:
Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
        CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2

pinentry:

ben@frodo:~$ pinentry-tty --version
pinentry-tty (pinentry) 1.1.0
Copyright (C) 2016 g10 Code GmbH
License GPLv2+: GNU GPL version 2 or later <https://www.gnu.org/licenses/>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Emacs:

ben@frodo:~$ emacs --version
GNU Emacs 26.3
Copyright (C) 2019 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

Doom's current HEAD:

ben@frodo:~/.emacs.d$ git log -1 --stat > foo.txt && cat foo.txt
commit 0ff85015f8734f81f71fe188e156b2aea2a86981
Author: Henrik Lissner <henrik@lissner.net>
Date:   Thu Feb 11 23:33:28 2021 -0500

    s/defadvice!/advice-add in comp config block

    Part 2 of 811099282.

    The latest build of native-comp appears to eagerly load comp very early,
    so defadvice! won't be defined when this block runs, causing this error.

 core/core.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

And Ubuntu:

ben@frodo:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.10
Release:        20.10
Codename:       groovy

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:unknownCause unknown; cannot be reproduced; cannot investigate further

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions