GPG 错误代码 2
GPG 的结果总是返回 2。我的代码如下
$cmd = "/usr/bin/gpg -a --recipient $to -e -o $outfile $infile";
其中 outfile 是加密数据所在的文件write和infile是未加密的数据。
我不知道为什么会发生这种情况。谁能告诉我出了什么问题。谢谢。
GPG is always returning 2 at the result. My code is as follows
$cmd = "/usr/bin/gpg -a --recipient $to -e -o $outfile $infile";
Where outfile is the file where the encrypted data will be written and infile is the unencrypted data.
I don't know why this is happening. Can anyone please tell me what's wrong. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
GPG 询问您是否要继续使用未签名密钥进行加密。由于没有用户可以输入
Y
,因此会产生错误。要解决此问题,请使用以下开关
--yes
和--always-trust
GPG is asking whether you want to continue on with the encryption using an unsigned key. Since no user can input
Y
it produces an error.To fix this put the following switches
--yes
and--always-trust
请参阅此消息: http://lists.gnupg.org/pipermail /gnupg-users/2008-January/032410.html
这似乎是一个权限问题。 gpg 正在尝试访问它无法访问的目录,因此失败并出现致命错误。 (错误代码 2)
您可以通过指定带有 gpg 可写目录的 homedir 指令来修复该问题。像这样:
来自
man gpg
的信息:See this message: http://lists.gnupg.org/pipermail/gnupg-users/2008-January/032410.html
It appears to be a permission problem. gpg is trying to access a directory that it can't have access to, so it fails with a fatal error. (error code 2)
You can fix that by specifying a homedir directive with a directory writable by gpg. Like this:
Information from
man gpg
:您可能还想考虑将密钥添加到受信任的密钥列表中:
我遇到了一些
--always-trust
参数在 XP Windows 上无法正常运行的问题,这帮助我解决了问题。You also might want to concider adding key to trusted keys list:
I've had some problems of
--always-trust
parameter not functioning properly on XP windows, this helped me solve the problem.我遇到了同样的问题,但是对于解码命令
首先,一般来说,您可以通过将 stderr 重定向到 stdout 来获取错误消息。
然后你可以修改gpg的参数来满足你的需要。因为我有一个使用带有密码短语的密钥加密的文件,所以我必须添加几个参数。
我开始
但它抱怨它无法打开 tty,然后使用 --no-tty 它输出一些其他错误,最后使用带密码短语的密钥解码文件的命令是
我希望这对某人有帮助。
I had the same problem, but for the decoding command
At first and general, you can get the error message by redirecting stderr to stdout.
Then you can modify gpg's parameters to suit your needs. Because I had a files encrypted with a key with pass phrase I had to add several parameters.
I started with
But it complained, that it can not open tty, then with --no-tty it outputs some other errors and finally the command for decoding files with key with pass phrase is
I hope this helps someone.