Pet*_*rch 5 bash gnupg gpg-agent
我试图使用gpg到--clearsign一个文件(Debian的包装用途)从脚本。
我有一个导出的无密码private-key.gpg文件,想要:
gpg --clearsign -o output input
Run Code Online (Sandbox Code Playgroud)
我不想与当前用户的混乱~/.gnupg或者/run/user/$(id -u)/gnupg是因为他们什么都没有做我的脚本。另外,该脚本可能同时在多个实例中运行,我不希望它们相互干扰。
我认为那很容易。设置$GNUPGHOME为临时目录并完成。但我无法弄清楚如何让gpg一个脚本,而不与用户的标准配置搞乱运行在所有。似乎gpg已竭尽全力使之无法避免,gpg-agent并gpg-agent坚持使用全局/硬编码路径。
我可以保留一切下$GNUPGHOME?或者如何在gpg不影响用户配置或脚本的使用gpg或其他实例的情况下从shell脚本安全使用?
阅读gpg文档,我发现:
--use-agent
--no-use-agent
This is dummy option. gpg always requires the agent.
Run Code Online (Sandbox Code Playgroud)
和gpg-agent文件说:
--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 Code Online (Sandbox Code Playgroud)
这个“标准套接字”大概是在/run/user/$(id -u)/gnupg-所以看来我无法避免gpg弄乱了用户对gpg的“正常”使用。
版本:Debian 9上的gpg 2.1.18 /拉伸/稳定
如果您无法阻止 gpg 创建文件,那么为 gpg 提供一个当前进程特有的放置文件的位置会有帮助吗?
# Create a temporary directory for gpg.
dir="$(mktemp -d)"
# Remove the directory and its contents when the script exits.
trap '[[ ! -d "${dir}" ]] || rm -r "${dir}"' EXIT
# Put your private-key.gpg in the temporary directory.
$(your command here)
# Tell gpg to use the temporary directory.
gpg --homedir "${dir}" --clearsign -o output input
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
212 次 |
| 最近记录: |