抑制 gnupg 中的警告消息

Aru*_*ese 3 bash gnupg

我使用 gpg 只是为了加密和解密。

我使用的命令是:

for enc:
gpg --sign test
for dec:
gpg --decrypt test.gpg > test
Run Code Online (Sandbox Code Playgroud)

但我收到以下警告消息:

gpg: Signature made Fri Jun 24 17:29:00 2016 UTC using RSA key ID XXXX
gpg: Good signature from "XXXX@xxxx.com>"
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the owner.
Run Code Online (Sandbox Code Playgroud)

当然,我已经尝试过 --status-fd, --no-comment, --no-mdc-warning,--no-tty ,--no-verbose --quiet --batch, --no-greeting etc基于互联网搜索。

有没有办法摆脱这些警告信息?

作为最后一个选项,我使用 如何在 bash 中隐藏命令输出

但我认为应该有一个简单的方法来抑制 gpg 中的警告。

hee*_*ayl 9

警告显示在 STDERR 上,您可以将 STDERR 流重定向到/dev/null以消除警告:

gpg --decrypt test.gpg 2>/dev/null
Run Code Online (Sandbox Code Playgroud)

也保存标准输出:

gpg --decrypt test.gpg 2>/dev/null >test
Run Code Online (Sandbox Code Playgroud)