Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gpg: error Inappropriate ioctl for device

I'm running a self-hosted Renovate instance and I need to sign the commits to GitLab with GPG key.
For this I'm setting the env variable RENOVATE_GIT_PRIVATE_KEY with the PGP private key block for my GitLab user and this is automatically imported.
But I get the following error when trying to do so:

gpg: directory '/home/ubuntu/.gnupg' created
gpg: keybox '/home/ubuntu/.gnupg/pubring.kbx' created
gpg: /home/ubuntu/.gnupg/trustdb.gpg: trustdb created
gpg: key 72A96C0D4FA8543C: public key "Dummy User <[email protected]>" imported
gpg: key 72A96C0D4FA8543C/72A96C0D4FA8543C: error sending to agent: Inappropriate ioctl for device
gpg: error building skey array: Inappropriate ioctl for device
gpg: error reading '/tmp/git-private.key': Inappropriate ioctl for device
gpg: import from '/tmp/git-private.key' failed: Inappropriate ioctl for device
gpg: Total number processed: 0
gpg:               imported: 1
gpg:       secret keys read: 1

I did the setup following this instructions https://docs.renovatebot.com/self-hosted-configuration/#gitprivatekey

like image 461
Fox Avatar asked Nov 26 '25 00:11

Fox


2 Answers

I fixed the inappropriate ioctl issue by adding export GPG_TTY=$(tty) prior the command execution

like image 174
Fox Avatar answered Nov 28 '25 15:11

Fox


You can fix it telling gpg to not rely on a terminal, like reading keyboard (stdin) and so, using the argument --batch.

Considering it is being run by a script the passphrase is expected to be provided by other means, like by --passphrase argument, so a full example:

$ gpg --batch --passphrase ${my_passphrase} --import ${key_path}
like image 38
Luciano Avatar answered Nov 28 '25 16:11

Luciano