DEV Community

Marco Belo
Marco Belo

Posted on • Updated on

Linux - workaround for pinentry [ERR 83918950 Inappropriate ioctl for device]

My workaround will results in a terminal command that will ask for your GPG password, it'll not be a working popup from pinentry.

I did this because I was having this error with pinentry:

# I'm running Manjaro KDE 21.3.5
$ echo GETPIN | pinentry
OK Pleased to meet you
S ERROR curses.isatty 83918950
ERR 83918950 Inappropriate ioctl for device <Pinentry>
Enter fullscreen mode Exit fullscreen mode

I'll assume that if you got to this point, you've already created your GPG key and know something about the gnupg and git config files.

Here's what I've in my configs:

# .zshrc, .bashrc...
export GPG_TTY=$(tty)
Enter fullscreen mode Exit fullscreen mode
# gpg-agent.conf
pinentry-program /usr/bin/pinentry-curses
max-cache-ttl 60480000
default-cache-ttl 60480000
Enter fullscreen mode Exit fullscreen mode
# gpg.conf
use-agent
pinentry-mode loopback

default-key  XXXXXXXXXXXXXXXX
Enter fullscreen mode Exit fullscreen mode
# .gitconfig
[user]
    name = xxx
    email = xxx
    signingkey = XXXXXXXXXXXXXXXX
[gpg]
    program = gpg2
[commit]
    gpgsign = true
Enter fullscreen mode Exit fullscreen mode

Solution

We are going to create a script to be call by an alias:

# .zshrc, .bashrc...
alias unlock_gpg="~/.unlock_gpg.sh"
Enter fullscreen mode Exit fullscreen mode
# ~/.unlock_gpg.sh  <- create this file and add the script below
current_dir=$(pwd)
cd ~/.unlock_gpg
git add .
git commit -m "abc"
git reset --soft HEAD~1
cd $current_dir
Enter fullscreen mode Exit fullscreen mode
# Run this command:
$ chmod +x ~/.unlock_gpg.sh
Enter fullscreen mode Exit fullscreen mode

Now create a folder with a git repo following the steps below:

$ mkdir ~/.unlock_gpg/
$ cd ~/.unlock_gpg/
$ git init
$ touch file.txt
$ git add .
$ git commit -m "first commit"
# if gpg ask for your password, provide it
$ echo 'hi' > file.txt

# This will reset your gpg agent, so you can test it below.
$ gpgconf --reload gpg-agent
Enter fullscreen mode Exit fullscreen mode

Now try it out:

$ unlock_gpg
# Now you should see a password prompt like this:
Enter passphrase:
# Just enter your password and sign your commits as you wish
Enter fullscreen mode Exit fullscreen mode

If you have a better/definitive solution please comment.

Oldest comments (0)