2013-10-24 42 views
1

我试图解密使用2个收件人(--recipient [email protected] --recipient [email protected])加密的文件。 但是,当我尝试解密文件时,它总是请求第一个收件人的密码。当第一个收件人秘密密钥不是钥匙圈的一部分时,它会给出一个错误'找不到秘密钥匙'。GPG - 使用多个收件人解密

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

(对我来说,这个问题似乎很简单和基本的功能 - 但显然,我不能让它开始工作)

预先感谢您!

+0

看起来这已经解决了。在gpg(GnuPG)1.4.11中,gpg首先会检查您是否拥有私钥,然后只有拥有该密钥才会询问密码,这显然是合理的顺序;) – Echsecutor

回答

3

今天我遇到了这个问题,并发现你的问题寻找答案。我看到很多快乐的例子如何加密事情多个收件人......从来没有说/当一个人试图解密该数据会发生什么。下面是我的了:

[email protected] ~ $ gpg --decrypt filename.pgp 

You need a passphrase to unlock the secret key for 
user: "SOMEBODY ELSE <[email protected]>" 
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! <[email protected]>" 
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 protected]>" 
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! <[email protected]>" 

and then the file decrypted fine... 

快速注:只是为了澄清,for security reasons自己的密码和自己的private key应该NEVER给予其他任何人。 The passphrase is to keep the private key "safe" should it become compromised. One's 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,而如果我读正确,可能是我们俩都在寻找?

+1

非常好的研究。谢谢。还有另外一种选择,为了方便,这取决于你的用例。您可以使用选项--secret-keyring,并使用正确的密钥将(临时)密钥环传递给gpg。通过这种方式,您可以将决定外化为gpg(例如。你可以在gpg中编写一个包装脚本)。 – nus

0

我也面临这个问题,今天我已经在批处理模式下运行GPG解决它:

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