【发布时间】:2019-03-07 17:46:18
【问题描述】:
我正在尝试使用 gpg 到 --clearsign 一个文件(用于 debian 打包目的)来自脚本。
我有一个导出的无密码private-key.gpg 文件并希望:
gpg --clearsign -o output input
我不想弄乱当前用户的~/.gnupg 或/run/user/$(id -u)/gnupg,因为它们与我的脚本无关。此外,脚本可以同时在多个实例中运行,我不希望它们相互干扰。
我认为这很容易。将$GNUPGHOME 设置到临时目录并完成它。但我无法弄清楚如何让gpg 在脚本中运行而不弄乱用户的标准配置。似乎gpg 已经竭尽全力避免gpg-agent 和gpg-agent 坚持使用全局/硬编码路径。
我可以将 所有内容 保留在 $GNUPGHOME 下吗?或者我如何在不影响用户配置或使用gpg 或我的脚本的其他实例的情况下安全地使用 shell 脚本中的 gpg?
详情
阅读gpg docs我看到了:
--use-agent
--no-use-agent
This is dummy option. gpg always requires the agent.
然后gpg-agent docs 说:
--use-standard-socket
--no-use-standard-socket
--use-standard-socket-p
Since GnuPG 2.1 the standard socket is always used.
These options have no more effect. The command gpg-agent
--use-standard-socket-p will thus always return success.
这个“标准套接字”大概在/run/user/$(id -u)/gnupg - 所以看来我无法避免 gpg 与用户对 gpg 的“正常”使用相混淆。
版本:Debian 9/stretch/stable 上的 gpg 2.1.18
【问题讨论】: