I just finished compiling the GnuPG (version 2.2.9) and all its dependencies for a Mac OS High Sierra. It was quite interesting. After solving a small problem with the tests of libgcrypt (with a little help of the respective recipe from Homebrew), everything worked basically out of the box.
While trying to import my private key, I couldn't, because the system was lacking a pinentry program. A quick search made me land on this page, but it wasn't very helpful, so I simply decided to compile the pinentry myself.
I already knew, from my experience using GnuPG on Linux machines, that I would like to type my password in a normal prompt on the command line, without those annoying, disrupting dialog boxes. And that's why I'm sharing the process here. It's simple, but might help someone with a similar problem.
Start by getting the source code of pinentry from GnuPG. Check their website. At the time of writing, the link to download the source was https://gnupg.org/ftp/gcrypt/pinentry/pinentry-1.1.0.tar.bz2. Download also the signature and check the authenticity using gpg itself.
DON'T SKIP THE VERIFICATION, this is important! This program will have access to all your gpg passwords and private keys. You better make sure it is what it claims to be! If you have problems, make sure you have imported the keys from the maintainers of GnuPG (see here):
$ gpg --verify pinentry-1.1.0.tar.bz2.sig pinentry-1.1.0.tar.bz2
Now that you are sure you are working with authentic source files, extract the source code and cd
in that directory:
$ tar xvf pinentry-1.1.0.tar.bz2
$ cd pinentry-1.1.0
The compilation is very straight forward:
$ ./configure --enable-pinentry-tty
$ make
$ sudo make install
It might be that configure
will complain about some missing dependency. It that case, simply read the error and download the dependency from GnuPG webpage (always checking for the integrity of the download!).
The important bit of the commands above is the flag --enable-pinentry-tty
. Pinentry TTY is the simplest way to type your password in a very normal and boring prompt on the command line. Exactly what I wanted! If I'm not mistaken, the curses
version will be built anyways. Although it's a CLI option, I find it as disruptive as all the others.
Once it's installed, you will see some new binaries in /usr/local/bin
. Make sure you have one called pinentry-tty
(if you don't, something went wrong...).
To make that new binary your default way of typing the gpg password, add the following line to ~/.gnupg/gpg-agent.conf
(create the file and directory if they don't exist yet):
pinentry-program /usr/local/bin/pinentry-tty
It won't probably work if you try immediately, because you most likely still have an gpg-agent running with old configuration. Go ahead and kill all the gpg-agents and create a new one:
$ sudo killall gpg-agent
$ gpg-agent --daemon
That's it! Enjoy you old-style TTY pinentry :)