Skip to content

Instantly share code, notes, and snippets.

@syntaxbender
Forked from mjul/GPG-FIX.md
Created January 2, 2026 22:04
Show Gist options
  • Select an option

  • Save syntaxbender/a2ff42c92f36afc937f037767a505fe1 to your computer and use it in GitHub Desktop.

Select an option

Save syntaxbender/a2ff42c92f36afc937f037767a505fe1 to your computer and use it in GitHub Desktop.
gpg: signing failed: Inappropriate ioctl for device

Fixing GPG "Inappropriate ioctl for device" errors

6th November 2016 Linux 24 Comments https://d.sb/B5N 
    Error: gpg: using "D5673F3E" as default secret key for signing 
    Error: gpg: signing failed: Inappropriate ioctl for device 
    Error: gpg: [stdin]: sign+encrypt failed: Inappropriate ioctl for device

It turns out this error is due to changes in GnuPG 2.1, which only recently landed in Debian Testing. The error occurs because GnuPG 2.1 by default ignores passphrases passed in via environment variables or stdin, and is trying to show a pinentry prompt. "Inappropriate ioctl for device" is thrown because the Backupninja script is not running through a TTY, so there's no way to actually render the prompt.

To solve the problem, you need to enable loopback pinentry mode. Add this to ~/.gnupg/gpg.conf:

    use-agent 
    pinentry-mode loopback

And add this to ~/.gnupg/gpg-agent.conf, creating the file if it doesn't already exist:

    allow-loopback-pinentry

Then restart the agent with echo RELOADAGENT | gpg-connect-agent and you should be good to go!

Source: https://d.sb/2016/11/gpg-inappropriate-ioctl-for-device-errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment