Recently I moved all my sites onto a new server. I use Duplicity and Backupninja to perform weekly backups of my server. While configuring backups on the new server, I kept encountering a strange error:
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!
Comments
this post's date is out of bounds ;)
What do you mean by that?
Thank you for sharing this. Now my maven deploys.
I'm glad you found it useful!
Thank you! That finally helped!
Another thanks from me! Always annoying when backwards compatibility is an option yet neither enabled by default nor well documented.
Just upgraded to Debian Stretch and had this error with Duply & Duplicity. Thank you very much for this post, it works now!
I'm glad you found it useful! I encountered the same issue with Backupninja + Duplicity and it took me a while to figure out how to fix it.
Thanks, It helped me a lot !
Still an extremely helpful post. Thank you! Works in the WSL, too, without any adjustments. Git will now sign tags, hooray! :)
Thank you, it really helped
Worked for me. Thanks!
Thanks. This works fine!
Thank you! This is exactly what I wanted
thank you so much!
worked like a charm on debian 9.9. Thank you for sharing
Many thanks!!
Worked great, thanks so much! It seems this issue is still there even with the most up-to-date gpg (almost four years after you posted this)!
What about use --pinentry-mode loopback ?
I admire so much all these people who give us solution for our problem... THANK YOU
Wish I had found this earlier! I removed use agent and manually entered the passphrase as an alternate way to solve this.
Thanks for the tip. It works most of the time. But because of https://dev.gnupg.org/T3465, it does not work with `--delete-secret-keys`, which confused me a while. I chose to use `pinentry-mac` on my mac machine instead.
A-ha! Many thanks!
Had this experience on a mac. Worked without having to reload the agent.
After 6 years, this is still valid. Thank you.
tyvm!
Finally!!! Simple, short and working solution. Thank you.
FYI - still fixes the problem in June, 2024 with GnuPG 2.2.27 on Ubuntu 22.04.4 LTS