【问题标题】:GPG - decrypt with multiple recipientsGPG - 与多个收件人一起解密
【发布时间】:2013-11-02 22:32:31
【问题描述】:

我正在尝试解密已使用 2 个收件人(--recipient recipientA@example.com --recipient recipientB@example.com)加密的文件。 但是,当我尝试解密文件时,它总是要求第一个收件人的密码。当第一个接收者密钥不是密钥环的一部分时,它会给出错误“找不到密钥”。

如何加密具有多个收件人的文件,以便双方都可以在不知道彼此密钥和密码的情况下对其进行解密?

(对我来说,这个问题似乎很简单,而且是一个基本功能 - 但显然我无法让它发挥作用)

提前谢谢你!

【问题讨论】:

  • 看来这个问题已经解决了。在 gpg (GnuPG) 1.4.11 中,gpg 会先检查你是否有私钥,然后只有在你有的时候才询问密码,这显然是合理的顺序;)

标签: encryption gnupg


【解决方案1】:

我今天遇到了这个问题,发现你的问题正在寻找答案。我已经看到很多关于如何为多个收件人加密 事物的示例......从不说/展示当一个人尝试解密该数据时会发生什么。这是我得到的:

user@system ~ $ gpg --decrypt filename.pgp

You need a passphrase to unlock the secret key for
user: "SOMEBODY ELSE <somebody_else@example.com>"
2048-bit ELG-E key, ID ABC1234, created 1972-10-29 (main key ID ABC5678)

gpg: Invalid passphrase; please try again ... [I DON'T HAVE *THEIR* PASSPHRASE!]

2 more times... finally...

You need a passphrase to unlock the secret key for
user: "HEY!  This is ME! <my_email@example.com>"
2048-bit ELG-E key, ID DEF1234, created 1969-02-03 (main key ID DEF5678)

gpg: encrypted with 2048-bit ELG-E key, ID ABC1234, created 1972-10-29
      "NAME <email@example.com>"
gpg: public key decryption failed: bad passphrase
gpg: encrypted with 2048-bit ELG-E key, ID DEF1234, created 1969-02-03
      "HEY!  This is ME! <my_email@example.com>"

and then the file decrypted fine...

快速说明: 澄清一下,for security reasonsprivate key 的密码应该绝不提供给其他任何人。 The passphrase is to keep the private key "safe" should it become compromised. 一个人的 public 密钥是唯一应该与他人共享的东西。

我以我目前只能访问版本 1.4.2.2 并且没有能力测试这些解决方案的事实作为开头。更高版本具有某些选项,很可能是需要的。 如果其中任何一项有效,请尝试并回复。

--local-user/-u 看起来很有希望。在我的版本中,--help 显示为use this user-id to sign or decrypt,但是当尝试它似乎是徒劳的时,进一步的研究揭示了一个残酷的事实:seems the help is wrong,这只是用于"signing" 的选项。

This post 有一个可能的解决方案,虽然我个人觉得它很乱:

gpg --try-all-secrets --passphrase <passphrase here> filename.pgp

--passphrasewas apparently added in version 1.4.3。啊!

编辑: Perhaps a better (possibly, below) solution is only available in gpg2? gpg2 seems to have --try-secret-key,如果我没看错,这可能是我们都在寻找的东西?

【讨论】:

  • 非常好的研究。谢谢。还有另一种选择,是否方便取决于您的用例。您可以使用选项 --secret-keyring 并将(临时)密钥环传递给 gpg,其中包含正确的密钥。通过这种方式,您可以将决定从 gpg 外部化(例如,您可以围绕 gpg 编写一个包装脚本)。
【解决方案2】:

我今天也遇到了这个问题,我通过批处理模式运行 gpg 解决了这个问题:

/usr/bin/gpg --batch --passphrase "your_passphrase" --verbose --decrypt

【讨论】:

    猜你喜欢
    • 2013-09-28
    • 2020-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-07
    • 1970-01-01
    • 2011-09-02
    • 2012-12-23
    相关资源
    最近更新 更多