Skip to content

Instantly share code, notes, and snippets.

@CMCDragonkai
Last active November 5, 2023 07:04
Show Gist options
  • Save CMCDragonkai/2a99df87f280df835e9b7e190d8f46ec to your computer and use it in GitHub Desktop.
Save CMCDragonkai/2a99df87f280df835e9b7e190d8f46ec to your computer and use it in GitHub Desktop.
Managing the gpg-agent #nix #gpg

Managing the gpg-agent

These are the standard commands:

gpgconf --list-dirs
gpgconf --kill gpg-agent
gpgconf --reload gpg-agent

If you have enabled the programs.gnupg.agent.enable = true; in NixOS use these instead:

systemctl --user status gpg-agent
systemctl --user reload gpg-agent
systemctl --user restart gpg-agent

The sockets will be opened at /run/user/UID/gnupg instead of the normal location of ~/.gnupg.

Note that there should be a gpg-agent per user (including the root user). Check with this:

ps -Af | grep gpg

Using gpg as root has some complications especially if you entered via sudo -i (login environment). The problem is that the tty is still not owned by the root user, so pinentry programs will fail. You need to ensure that your $(tty) is owned by the root user or instead use the option --pinentry-mode=loopback when running gpg2. See this: https://wiki.archlinux.org/index.php/GnuPG#su

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment