AWS Airflow (mwaa) and decryption using Python gnupg library

Hello,

has anybody able to achieve decryption of file in AWS Airflow using gnupg decrypt_file?
I get the below error

gpg: encrypted with rsa2048 key, ID 663F6D92B5XXXX, created 2022-07-28
      "XXXXX"
gpg: error running '/usr/bin/gpg-agent': probably not installed
gpg: failed to start gpg-agent '/usr/bin/gpg-agent': Configuration error
gpg: can't connect to the gpg-agent: Configuration error
gpg: error running '/usr/bin/gpg-agent': probably not installed
gpg: failed to start gpg-agent '/usr/bin/gpg-agent': Configuration error
gpg: can't connect to the gpg-agent: Configuration error
gpg: keydb_search failed: No agent running
[GNUPG:] NO_SECKEY 663F6D92B5******
gpg: public key decryption failed: No secret key
[GNUPG:] ERROR pkdecrypt_failed 33554449
[GNUPG:] BEGIN_DECRYPTION
[GNUPG:] DECRYPTION_FAILED
gpg: decryption failed: No secret key
[GNUPG:] END_DECRYPTION

I imported the private key and I can see the key under subkeys when doing a list_keys.
Any help would be much appreciated.

Hi @sg-schaudhuri ,

can you give use the version of GnuPG that is installed there and the GNU/Linux distribution used for the image?

(Calling gpg --version should give you some details about the version. Then cat cat /etc/os-release potentially gives you details about the GNU/Linux distribution. Then you need a distribution depending command to find out where gnupg came from and how you could get gpg-agent.)

The installation seems incomplete as gpg-agent is needed to do crypto operations. Have you checked if it is installed and how you could install it?

The machine is a Amazon Linux 2023 and the package installed is gnupg2-minimal-2.3.7-1.amzn2023.0.4.x86_64

According to GNU Privacy Guard (GNUPG) - Amazon Linux 2023
you need to do

dnf swap gnupg2-minimal gnupg2-full

to use a secret key.

1 Like

That was indeed the solution! Thank yo so much Bernhard!