使用公钥验证加密文件

时间:2015-09-25 01:42:03

标签: public-key-encryption gnupg

我有一个服务器在托管与gnupg模块,一切正常。用户可以使用我的公钥来加密消息(此过程应该在本地,而不是在服务器中)并在我的服务器中上传此消息。我想验证"文件"用我的公钥加密

用户输入类似内容,然后将文件上传到我的服务器中。

gpg --encrypt --recipient 12345678 file.txt  

我不想在此服务器中共享我的私钥,所以我无法验证我是否可以解密。我的问题是,我可以使用自己的公钥来验证哪个文件被加密了吗?

对不起我的英文

1 个答案:

答案 0 :(得分:0)

使用gpg --decrypt但不提供私钥,gpg将告诉您加密的所有密钥:

wwalker@hatter:~$ gpg --decrypt foo.asc

You need a passphrase to unlock the secret key for
user: "Wayne Walker (Ruby Hacker) <wwalker@bybent.com>"
4096-bit ELG-E key, ID 39D0C3D7, created 2007-12-31 (main key ID A62B624A)

gpg: cancelled by user
gpg: encrypted with 1024-bit ELG-E key, ID 70DAE878, created 2015-10-15
      "Puppet Vault (Used for targeted secrets exchanges) <puppet@pumhost2.lbl.gov>"
gpg: encrypted with 1024-bit ELG-E key, ID 9426026B, created 2015-10-15
      "Puppet Vault (Used for targeted secrets exchanges) <puppet@jenkins.lbl.gov>"
gpg: encrypted with 4096-bit ELG-E key, ID 39D0C3D7, created 2007-12-31
      "Wayne Walker (Ruby Hacker) <wwalker@bybent.com>"
gpg: public key decryption failed: bad passphrase
gpg: decryption failed: secret key not available

如果您已经在使用gpg-agent,并且您的密钥已经在代理中:

(unset GPG_AGENT_INFO; gpg --decrypt foo.asc)