3

I recently set up Ubuntu in a VM for development work, but found that git couldn't sign my commits. Investigating further, I found that gpg-agent wasn't able to request my passphrase via pinentry-curses, producing the Inappropriate ioctl for device error, even though my GPG_TTY is set correctly:

$ echo 'this is a test' | gpg --status-fd=2 -bsau <<my-key-short>>
[GNUPG:] KEY_CONSIDERED <<my-key-long>> 2
[GNUPG:] BEGIN_SIGNING H8
[GNUPG:] PINENTRY_LAUNCHED 1207
gpg: signing failed: Inappropriate ioctl for device
[GNUPG:] FAILURE sign 83918950
gpg: signing failed: Inappropriate ioctl for device

$ echo $GPG_TTY
/dev/pts/0

However, if I kill gpg-agent and start it manually — using the exact same arguments I see for the auto-started agent, reported by ps — it's then able to prompt me for my password and signs without problem:

$ ps x
   PID TTY      STAT   TIME COMMAND
   922 ?        S      0:00 sshd: five35@pts/0
   923 pts/0    Ss     0:00 -bash
  1205 ?        Ss     0:00 gpg-agent --homedir /home/five35/.gnupg --use-standard-socket --daemon
  1224 pts/0    R+     0:00 ps x

$ gpgconf --kill gpg-agent

$ gpg-agent --homedir /home/five35/.gnupg --use-standard-socket --daemon
gpg-agent[1276]: WARNING: "--use-standard-socket" is an obsolete option - it has no effect
gpg-agent[1277]: gpg-agent (GnuPG) 2.1.15 started

$ echo 'this is a test' | gpg --status-fd=2 -bsau <<my-key-short>>
[GNUPG:] KEY_CONSIDERED <<my-key-long>> 2
[GNUPG:] BEGIN_SIGNING H8
[GNUPG:] PINENTRY_LAUNCHED 1295
[GNUPG:] SIG_CREATED D 1 8 00 1503763837 <<my-key-long>>
-----BEGIN PGP SIGNATURE-----

iQIcBAABCAAGBQJZoZ19AAoJEKT/kfDdu6RyXJYP/RBNUVXFkWahcYcaGs4LkC5Y
G9bcMnNgGdVZt5XXq28jjc3KRNkwC1taHK+TcNutGoK7vbnnB8dmZ2/M5mHkvzCt
Cdm7YBp0QevUIRNoJis402/nmBXG3wEwne97B0kC32aY6i2pPMl+x0ZVbrZ15mXk
mhvk+Yd126x/HQ2B5buFN1rnh1oXdm6vo6EZXjTI6uCYlEeIMJUqdWhys7lf2TNr
3wCyrVvPx44RY92vtKSdJW0eZNhzMqdopjyaO/TPMPZxQiH7t0/rJk98eLyEAkBT
kcW6iDTwZWWgA3I4X1Q0JIKnc33jRXnOuLWcPEOSYKczssQx6xXNS43vskaaz2Rz
/U6NsaF0BuTQY9LcT1nKRwyoB1SXPgBss0j/E0MvZEHYTQfRPuAffJgZvQyIEjGf
6DPicQ45hltPaiFekXtTBd47ilyvyWCYO6qnCjDpTFxLXw3y4PseA79GrkQ2YRiS
Tzb6faW+/pgFlcXpMpCZATGde0o/KQZdTSZ5TpvlAf4N8uBdppObxuhDnzS2BeR6
/pqmP+/cw+txb7peNrvbIjwQcNsAkp5M8lG0hPJEecHXkivEck7zsgC6ua+Fy/Ic
3LicU01YvzIGq2r703pZpFWcoayPEdn5BCtyRElwON/Vk98930QCOu65WqF4WOmJ
s1k429ihGjgTRqzOT6by
=uv8j
-----END PGP SIGNATURE-----

Further, if I have multiple terminals (SSH sessions) open, I will always be prompted for the password on the terminal which manually started gpg-agent.

How can I resolve this? I've already added export GPG_TTY=$(tty) to my .bashrc (the results of which can be seen above), running echo "UPDATESTARTUPTTY" | gpg-connect-agent, changing my TERM to just xterm, and unsetting DISPLAY. Unfortunately, none of these seem to have had any effect.

Host system:

  • Windows 10 Home 64-bit 1703 15063.540
  • PuTTY 0.70 64-bit

Client system:

  • Ubuntu 17.04
  • gpg 2.1.15
  • gpg-agent 2.1.15
  • pinentry-curses 1.0.0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.