Gpg: processing message failed: eof; Unix Error ksh GPG Script Decryption

I am new to writing Unix and ksh script. I wrote a script that decrypts a gpg message. I get this error, I don’t know how to solve it. I was hoping someone could look at my script and help me figure out what was going on. Thank you for any help you can provide. Here is the error:

gpg: processing message failed: eof 

Here is my script:

 #!/bin/ksh #################################################################### # 1. Decrypt Inbound File # # # # Two parms are required: output file # # encrypted file(to be decrypted) # # # #################################################################### # Variable declaration # #################################################################### outputF=$1 encryptedF=$2 id=$$ #################################################################### # print_message # # prints messages to log file # #################################################################### print_message() { message="$1" echo "`date '+%m-%d-%y %T'` $message" } ##################################################################### # Validate input parameters and existence of encrypted file # ##################################################################### if [ $1 -eq ""] || [ $2 -eq ""] then print_message "Parameters not satisfied" exit 1 fi if [ ! -f $encryptedF ] then print_message "$id ERROR: $encryptedF File does not exist" exit 1 fi ##################################################### # Decrypt encryptedF # ##################################################### gpg --output "$outputF" --decrypt "$encryptedF" echo "PASSPHRASE" | gpg --passphrase-fd 0 print_message "$id INFO: File Decrypted Successfully" 
+4
source share
1 answer

This is not a problem with gpg :-) Your script is trying to run the gpg binary file twice. The first call tries to decode the file:

 gpg --output "$outputF" --decrypt "$encryptedF" 

Since no means of entering a passphrase have been specified, gpg tries to read the passphrase from the console. What happens now depends on your gpg configuration, ksh behavior, etc., but I suspect that the interaction with STDIN has been crippled in some way, which leads to an EOF error.

Solution to your problem: you must add the source of the passphrase to the decryption call:

 echo "PASSPHRASE" | gpg --passphrase-fd 0 --output "$outputF" --decrypt "$encryptedF" 
+3
source

Source: https://habr.com/ru/post/1495415/


All Articles