Gpg decryption error

While trying to decrypt the secrets in single line command line below I was getting error.


cat file <or echo "whatever">  | base64 --decode | gpg -d

gpg: public key decryption failed: Inappropriate ioctl for device
gpg: decryption failed: No secret key

The reason for the key that you have used is password protected. The pipe won’t work with gpg if your key is password protected.


gpg --export "Jayesh-key" | base64 # To get your key

gpg --list-keys

In order to get that working. Either you remove pipe in 2 commands.


echo "whatever" | base64 --decode > file.gpg

gpg -d file.gpg

or you can modify your key to be without password by providing blank password but thats not a recommended or ideal way.


gpg --edit-key YourKey

gpg prmpt > passwd

Once it prompts enter existing password to unlock. Once done just enter for blank password.

gpg prompt > save