
Cuando uso gpg-agent con git tag -u, aparece el siguiente error inmediatamente:
gpg: cancelled by user
gpg: skipped "[email protected]": bad passphrase
gpg: signing failed: bad passphrase
error: gpg failed to sign the data
error: unable to sign the tag
gpg-agent.conf:
pinentry-program /usr/bin/pinentry-curses
Cuando desbloqueo la clave primero (a través de un gpg -e -s test.txt
), el git tag -u
comando toma la clave y firma la etiqueta como se esperaba.
Esto está en ubuntu 13.10, usando i3 wm. Sospecharía que gnome-keyring está de alguna manera obstaculizando... algo, pero en una raspberry pi, ejecutando archlinux-arm, funciona de la misma manera, pero con un problema ligeramente diferente: después de ejecutar el git tag -u
comando, solicita una contraseña para desbloquear, pero no aparece ninguna entrada ni mensaje. Después de un tiempo (unos 30 segundos), falla con lo siguiente:
gpg: problem with the agent: Line passed to IPC too long
gpg: skipped "[email protected]": Operation cancelled
gpg: signing failed: Operation cancelled
error: gpg failed to sign the data
error: unable to sign the tag
Nuevamente, una vez que desbloqueo la clave directamente gpg -s
a un archivo arbitrario para almacenar en caché las credenciales en gpg-agent, la etiqueta se firma sin problemas.
Mi suposición es que algo está raro con mi uso de pinentry-curses. Ya actualicé /usr/bin/pinentry para que apunte a /usr/bin/pinentry-curses, pero el problema persiste.
¿Qué estoy haciendo mal y cómo consigo que git funcione bien con gpg/pinentry?
- versión gpg de ubuntu: 1.4.14
- versión archlinux-arm gpg: gnupg-2.0.22-1
EDITAR: ejecutando zsh. Aquí está el bit relevante obtenido para el agente gpg:
if [ $EUID -ne 0 ] ; then
envfile="$HOME/.gnupg/gpg-agent.env"
if [[ -e "$envfile" ]] && kill -0 $(grep GPG_AGENT_INFO "$envfile" | cut -d: -f 2) 2>/dev/null; then
eval "$(cat "$envfile")"
else
eval "$(gpg-agent --daemon --write-env-file "$envfile")"
fi
export GPG_AGENT_INFO # the env file does not contain the export statement
fi
cuando sigo $(tty) (por ejemplo: /dev/pts/16
), la propiedad ya es user:tty
.
Respuesta1
También necesitarás exportar elGPG_TTYvariable cada vez que inicia un nuevo TTY (también se puede hacer desde archivos bash/zsh rc):
export GPG_TTY=$(tty)
Respuesta2
Los problemas con el cuadro de diálogo ncurses de Pinentry están relacionados con la propiedad del TTY que pinentry intenta utilizar (si inicialmente inicia sesión como usuario y luego su, por ejemplo).
Coloque el siguiente script en/etc/profile.d/gpg-agent.shpara solucionarlo (es posible que desee omitir el exterior if
en un sistema multiusuario o cambiar la condición a! =):
if [ "$(id -un)" = "root" ] ; then
envfile="$HOME/.gnupg/gpg-agent.env"
if [[ -e "$envfile" ]] && kill -0 $(grep GPG_AGENT_INFO "$envfile" | cut -d: -f 2) 2>/dev/null; then
eval "$(cat "$envfile")"
else
eval "$(gpg-agent --daemon --enable-ssh-support --write-env-file "$envfile")"
fi
export GPG_AGENT_INFO # the env file does not contain the export statement
export SSH_AUTH_SOCK # enable gpg-agent for ssh
GPG_TTY=$(tty)
chown $USER:tty $GPG_TTY # make pinentry-ncurses work
fi