gpg commands fail without offering password prompts

Solution Verified - Updated -

Issue

  • After using the su command to switch users, gpg doesn't allow entering a passphrase -- whether encrypting, decrypting, or generating a new key with gpg --gen-key. Example:

    $ gpg -d testfile.gpg  
    gpg: 3DES encrypted data  
    can't connect to `/root/.gnupg/S.gpg-agent': No such file or directory  
    gpg-agent[8750]: command get_passphrase failed: Operation cancelled  
    gpg: cancelled by user  
    gpg: encrypted with 1 passphrase  
    gpg: decryption failed: No secret key
    

Environment

  • Red Hat Enterprise Linux 6, 7, or 8
  • gpg2 rpm

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In