1

I'm trying to encrypt data from STDIN using gpg. I'm using the following:

echo 'plaintext' | gpg -c -o output.gpg

However, I see the following result:

gpg: problem with the agent: Inappropriate ioctl for device
gpg: error creating passphrase: Operation cancelled
gpg: symmetric encryption of '[stdin]' failed: Operation cancelled

How would I encrypt from STDIN using gpg and a symmetric cipher only? I am on MacOS and GPG v2.2.13.

2
  • Can not reproduce on arch linux with GnuPG 2.2.12. Can you tell us which --version of gpg you are using?
    – confetti
    Feb 26 '19 at 5:51
  • @confetti I'm using MacOS, if that makes a difference. GPG v2.2.13, updated the question
    – wcarhart
    Feb 26 '19 at 6:09
1

It is a problem with pinentry (utility used to register the passphrase). Is it installed on your mac? If not, run brew install pinentry-mac and try again, otherwise you need to change your configuration. Check the comment on this issue for details but this should be ok:

brew install pinentry-mac
echo "pinentry-program /usr/local/bin/pinentry-mac" >> ~/.gnupg/gpg-agent.conf
killall gpg-agent
6

Many people recommend installing pinentry-mac, a package that isn’t maintained by the official GnuPG team. I would recommend against it.

A more secure alternative is to append the following lines to ~/.profile as suggested in the official docs (appending them to ~/.bashrc didn’t work for me).

GPG_TTY=$(tty)
export GPG_TTY

Once these lines have been appended, close your terminal and the issue should be resolved.

Also, make sure you upgrade gnupg to the latest version using brew upgrade gnupg.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.