我使用 gpg
加密了一个文件,现在我想解密该文件。
有什么办法可以解密文件而不需要导入 secret 文件吗?
我们将 key 保存在名为 key.sec
的文件中;我们能否将 secret 文件作为参数传递给 gpg(当我们从 bash 命令行运行 decrypt
命令时)以在解密时使用加密文件?或者我们必须导入 key 然后解密加密文件?
最佳答案
您必须将 key 添加到 key 环中。来自 gpg(1)
文档:
--no-default-keyring
Do not add the default keyrings to the list of
keyrings. Note that GnuPG will not operate without any
keyrings, so if you use this option and do not provide
alternate keyrings via --keyring or --secret-keyring,
then GnuPG will still use the default public or secret
keyrings.
您可以--import --no-default-keyring --secret-keyringtemporary
导入 key ,解密时使用--secret-keyringtemporary
内容,然后在完成后删除 ~/.gnupg/temporary.gpg
文件。但这只是一种解决方法。
关于encryption - 使用外部 key 解密加密的 gpg 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9073288/