【问题标题】:gpg: processing message failed: eof ;Error Unix ksh GPG decryption Scriptgpg:处理消息失败:eof;错误 Unix ksh GPG 解密脚本
【发布时间】:2013-08-05 21:50:37
【问题描述】:

我是 Unix 和 ksh 脚本编写的新手。我写了一个解密 gpg 消息的脚本。我收到此错误,我不知道如何解决。我希望有人可以查看我的脚本并帮助我弄清楚发生了什么。感谢您提供的任何帮助。 这是错误:

gpg: processing message failed: eof

这是我的脚本:

#!/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"

【问题讨论】:

  • 您写道:I get this error that I do not know how to resolve... 请编辑您的消息以包含错误消息的确切文本。正如您所发现的,使用{} 编辑工具来保持消息的格式。祝你好运。
  • @shellter 更新了,你觉得你能帮忙吗?
  • 请编辑您的问题以显示您正在执行的gpg 行。所有其他代码看起来都很好,我会删除它,并且只发布gpg 的最简单的测试用例。 .....我不确定如何提供帮助,鉴于我对unix进程的一般了解,我希望您的2个命令合并为一个,并将gpg的输出发送到某处:像gpg ... > unecryptedFile 这样的重定向文件或分配给像myUnecryptedOutput=$(gpg .... ) 这样的shell 变量。您可以更新以包含使用一些简单输入短语的预期输出吗?祝你好运。

标签: unix ksh gnupg


【解决方案1】:

这不是 gpg 问题 :-) 您的脚本尝试运行 gpg 二进制文件两次。第一次调用尝试解码文件:

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

由于没有给出密码输入方式,gpg 尝试从控制台读取密码。现在会发生什么,取决于您的 gpg 配置、ksh 行为等,但我怀疑与 STDIN 的交互在某种程度上被削弱了,从而导致 EOF 错误。

您的问题的解决方案:您必须将密码源添加到解密调用中:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-04-03
    • 1970-01-01
    • 2018-02-23
    • 2022-06-14
    • 1970-01-01
    • 2011-04-12
    • 2017-09-16
    相关资源
    最近更新 更多