This is a wrapper shell script around pinentry that selects which pinentry program to call depending on the context (local or ssh).
Find a file
2024-02-02 00:00:00 +00:00
.gitignore feat: first version 2024-02-02 00:00:00 +00:00
pinentry-auto feat: first version 2024-02-02 00:00:00 +00:00
README.md feat: first version 2024-02-02 00:00:00 +00:00

Abstract

This is a wrapper shell script around pinentry that selects which pinentry program to call depending on the context.

In case a connection is detected as coming from SSH pinentry-curses is selected no matter what. If not, then the script will select an appropriate frontend.

Currently the only frontend used is /usr/bin/pinentry but in the future a configuration file and an auto selection will be implemented

Setup

Installation

Copy pinentry-auto to '/usr/local/bin/pinentry-auto':

# On Debian
install -m 755 -o root -g root ./pinentry-auto /usr/local/bin/pinentry-auto

Configuration

In your session init file (e.g. .bashrc, .zshrc, .profile, or any other appropriate file) ensure the following is set

export GPG_TTY="$(tty)"
export PINENTRY_USER_DATA="connect/greeter"                                                                                                               
{ [ -n "${SSH_CLIENT}" ] || [ -n "${SSH_CONNECTION}" ] || [ -n "${SSH_TTY}" ]; } && export PINENTRY_USER_DATA="connect/ssh"

Then create or edit the file "${HOME}/.gnupg/gpg-agent.conf so that it include this entry (only one pinentry-program line should exist):

pinentry-program /usr/local/bin/pinentry-auto