gpg: problem with the agent: Permission denied
13,500
Try using the PIN entry mode of loopback:
gpg --decrypt --pinentry-mode=loopback <file>
I can replicate your issue on my Linux system when I try GPG with a terminal su:
$ gpg --decrypt example.gpg
gpg: AES256 encrypted data
gpg: problem with the agent: Permission denied
gpg: encrypted with 1 passphrase
gpg: decryption failed: No secret key
The solution that works for me:
$ gpg --decrypt --pinentry-mode=loopback example.gpg
hello world
You may also want to verify that your GPG is up to date:
$ gpg --version
gpg (GnuPG) 2.2.4
libgcrypt 1.8.1
...
Related videos on Youtube
Comments
-
sashoalm almost 2 years
GPG fails with
gpg: problem with the agent: Permission denied
when I invoke it after switching my user withsu
:su - user2 gpg --symmetric --passphrase=foo foo.txt
If I invoke the command from my own user, it doesn't fail. Is there a workaround?
I found a thread a thread in their mailing list about it but it's unanswered. It speculates that the error is because:
the tty is owned by the original user I logged into via SSH, not the user I switched to via su
-
Amith KK over 5 yearsDid you try
script -c "gpg --symmetric --passphrase foo foo.txt" /dev/null/
-
jueti about 4 yearsI fix it by logging in user2 directly instead
su
from other users.
-
-
Deathgrip almost 3 yearsCan also add
pinentry-mode loopback
to your ~/.gnupg/gpg.conf file. -
carlin.scott over 2 years@Deathgrip your comment was more helpful to me than the answer. Every single command requires the --pinetry-mode option, so saving it to the config is a lifesaver.
-
Deathgrip over 2 yearsGlad I can help