【问题标题】:Encrypting file using GnuPG on command line hangs forever在命令行上使用 GnuPG 加密文件永远挂起
【发布时间】:2016-04-12 21:17:37
【问题描述】:

我想用 GnuPG 加密一个文件

    gpg2 --homedir=~/.gnupg --always-trust=true --recipient="BlahBlah" --encrypt=/path/to/file --output=/path/to/output_file

但是这个命令似乎永远挂起并且永远不会返回。有趣的是,在我中断进程后,确实有 /path/to/output_file created ,但是写入的字节比原始有效负载大得多(例如我的 /path/to/file 只有 5 个字节,但事实证明有将近 200 个字节写入 @ 987654324@).

肯定有问题,但我实在想不通。

我已经提前通过gpg --import key.asc 导入了BlahBlah 的密钥。 GnuPG 1 和 GnuPG 2 都会发生这种情况。

【问题讨论】:

    标签: encryption gnupg pgp openpgp


    【解决方案1】:

    您以错误的方式应用--encrypt--encrypt 不需要任何参数,要处理的文件作为最后一个参数传递。此外,按照文档,您应该传递--output /path/to/output_file 而不是--output=/path/to/output_file。最后,GnuPG 区分了选项和命令,选项应该在命令之前。

    您观察到 GnuPG 开始写入标头信息,但随后等待来自 STDIN 的输入(直到中断)。

    您要查找的 GnuPG 命令行是

    gpg2 --homedir=~/.gnupg --always-trust=true --recipient="BlahBlah" --output /path/to/output_file --encrypt /path/to/file
    

    最后一个提示:--always-trust=true 和通过用户 ID 解析收件人的组合是一个非常糟糕的主意,因为可能会使用本地密钥环中具有相同用户 ID 的任何其他密钥。而是传递完整密钥的指纹,这会专门选择一个不同的密钥 (using short key IDs is not secure, either)。

    【讨论】:

      猜你喜欢
      • 2012-11-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-21
      • 1970-01-01
      • 2022-10-17
      相关资源
      最近更新 更多