linux - gpg 解密在 LINUX "can' t 批处理模式下查询密码时出错”

标签 linux gnupg encryption passphrase

嗨,我正在使用 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.

检查phpinfo()


检查该功能是否被禁用:

$ 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/

相关文章:

java - Java 中可用的加密类型?

linux - Bash 脚本在 if elif else 语句中包含逻辑与和或

linux - 具有多个参数的 Gnu Parallel - 选择性命令执行

go - Go 的 openpgp 包中的 PGP key 装甲编码

git - GPG 签署所有没有 stash 的 git 提交

c# - GnuPG 加密不适用于进程错误代码 2

git - git push 和 pulls 是否加密?

c - 处理蝾螈回调

c - 如何修复编译项目时出现的警告

security - 密码散列、盐和散列值的存储