嗨,我正在使用 gpg 在 Linux 中解密文件,我正在使用
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
最佳答案
这个错误使得逗号和似乎不喜欢使用 shell_exec 运行(类似于 sudo/ssh 在使用 shell_exec 运行时警告需要 tyy 的方式)::
gpg: gpg-agent is not available in this session
如果您直接从 shell 提示符运行它会发生什么情况?
此外,请确保您未处于安全模式:
shell_exec() (functional equivalent of backticks) This function is disabled when PHP is running in safe mode.
检查该功能是否被禁用:
$ grep 'disable_functions' /etc/php.ini
编辑:
此外,尝试使用 putenv 将 GNUPGHOME 指向您的 .gnupg 文件夹。
可能是 php 脚本正在作为 httpd 用户运行,而 gpg 需要您站点的“user”用户。
关于linux - gpg 解密在 LINUX "can' t 批处理模式下查询密码时出错”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7506741/