Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
LINUX中的gpg解密给出错误“;can';t在批处理模式下查询密码短语“;_Linux_Gnupg_Encryption_Passphrase - Fatal编程技术网

LINUX中的gpg解密给出错误“;can';t在批处理模式下查询密码短语“;

LINUX中的gpg解密给出错误“;can';t在批处理模式下查询密码短语“;,linux,gnupg,encryption,passphrase,Linux,Gnupg,Encryption,Passphrase,Hi im使用gpg在linux中解密文件,im使用 shell_exec("gpg --batch --passphrase-file $passphrase_file -d $encrypted_file"); 解密文件,但我得到以下错误 gpg: gpg-agent is not available in this session gpg: can't query passphrase in batch mode gpg: Invalid passphrase; please try

Hi im使用gpg在linux中解密文件,im使用

shell_exec("gpg --batch --passphrase-file $passphrase_file -d $encrypted_file"); 
解密文件,但我得到以下错误

gpg: gpg-agent is not available in this session
gpg: can't query passphrase in batch mode
gpg: Invalid passphrase; please try again ...
gpg: can't query passphrase in batch mode
gpg: Invalid passphrase; please try again ...
gpg: can't query passphrase in batch mode

此错误使commaand看起来不喜欢使用shell_exec运行(类似于sudo/ssh在使用shell_exec运行时警告需要tyy):

如果直接从shell提示符运行它会发生什么

此外,请确保您的电脑未处于安全模式:

shell_exec()(与backticks功能等效) 当PHP在安全模式下运行时,此函数被禁用

核对


检查功能是否未被禁用:

$ grep 'disable_functions' /etc/php.ini

编辑:

另外,尝试使用putenv将GNUPGHOME指向.gnupg文件夹


可能是php脚本正在以httpd用户的身份运行,而gpg希望您的站点有“用户”用户。

我在从cron调用gpg时遇到了类似的问题。 从命令行或shell脚本运行时,该命令工作正常。从cron运行命令失败,错误与您得到的相同。 我发现两个资源是一个很好的gpg 及

在生成gpg密钥后,我能够让它工作

gpg --gen-key
然后使用以下命令进行加密:

gpg -e -r name@domain.tld backup_file.tgz
gpg -e -r name@domain.tld backup_file.tgz