当gpg-agent作为登录会话的一部分运行时,我运行的每个程序都可以访问我(可能)未锁定的 PGP 密钥。这可能是偏执的,但我想获得关于每个密钥使用的确认,所以我希望有一个选项gpg-agent,当密码或卡密码已经被缓存时,它会在允许访问密钥之前弹出一个确认对话框。
对于gpg-agent由此类选项管理的 ssh 密钥,根据联机帮助页存在,但不适用于 PGP。
我错过了什么?
没有仅显示消息的选项。最后,您必须从两个选项中进行选择:
完全禁用缓存,以确保根本不存储密码:
--max-cache-ttl n
Set the maximum time a cache entry is valid to n seconds. After
this time a cache entry will be expired even if it has been
accessed recently or has been set using gpg-preset-passphrase.
The default is 2 hours (7200 seconds).
Run Code Online (Sandbox Code Playgroud)
我不确定 的值是否0完全禁用缓存或将最大时间设置为无限 - 您将很容易找到答案。将其设置为1秒可能也可以。
有一个选项可以在签名时禁用缓存(而解密仍然使用它):
--ignore-cache-for-signing
This option will let gpg-agent bypass the passphrase cache for
all signing operation. Note that there is also a per-session
option to control this behaviour but this command line option
takes precedence.
Run Code Online (Sandbox Code Playgroud)
其背后的想法是防止意外签署消息(可能无法撤消),而意外解密消息可能不会造成伤害。
如果考虑这些选项,请考虑您想要减轻哪些攻击。如果任何人能够使用您的密钥执行操作,那么他很可能无论如何都能够运行任意命令,并且很可能安装木马或键盘记录器。