8

Whenever I try to create a signed git commit, I need to enter my GPG key. It spawns some GUI application to receive the password. It looked like the application was seahorse, so I uninstalled it, but git still uses some GUI app. Polybar doesn't report the application name and it's title is just [process]@MYPC.

How do I get git to use the command line / pinentry?

Versions:

  • gpg: 2.2.19
  • git: 2.25.1
  • pinentry: 1.1.0
karizma
  • 211
  • 2
  • 6

2 Answers2

13

This is a gpg configuration issue, not a git configuration issue.

You can force gpg to use a terminal-based dialog for entering your password by setting the pinentry-program in your gpg-agent.conf. For a simple terminal prompt, put the following in your ~/.gnupg/gpg-agent.conf:

pinentry-program /usr/bin/pinentry-tty

For a curses-based prompt:

pinentry-program /usr/bin/pinentry-curses
larsks
  • 32,449
  • 5
  • 54
  • 70
8

What's in your ~/.gnupg/gpg-agent.conf?

I have pinentry-program /usr/bin/pinentry-curses in mine, and everything which uses gpg will ask for my pass-phrase in the terminal.

NOTE: You will need to restart your gpg-agent (or send it a HUP signal) if you change its config. Just running gpgconf --kill gpg-agent will do, gpg will restart it when needed.

ALSO NOTE: the environment variable GPG_TTY needs to be your current tty (i.e. the tty you're currently running gpg in - or whatever calls gpg, such as mutt, pass, git, etc). So add the following to your ~/.bashrc (or whatever's appropriate for your shell):

GPG_TTY=$(tty)
export GPG_TTY

See man gpg-agent for details.

cas
  • 1
  • 7
  • 119
  • 185