如何让Makefile无密码使用gpg?
我有一个 Makefile,它调用 gpg 来解密文本文件,然后使用文本编辑器打开它进行编辑。因为我经常这样做,所以我想节省每次输入密码的时间,如何设置 gpg 来记住我最近通过了密码测试?例如,仅当我在过去 30 分钟内未输入密码时才触发我输入密码。
谢谢!
I have a Makefile that calls gpg to decrypt text files before opening it with a text editor for editting. Because I do it frequently, I'd like save time typing in password every time, how can I set up gpg to remember I passed the password test recently? For example, trigger me to type in password only if I haven't done it in the last 30 minutes.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为有两种方法可以做到这一点:
让
gpg
使用选项--passphrase-file
从文件中读取密码(但gpg手册页建议如果您可以避免的话,请不要使用此选项!我认为您可以按如下方式避免它...);使用
gpg-agent
来缓存密码。如果 shell 脚本每次都要求您输入密码,则可能没有代理在运行。如果 gpg-agent 正在运行,env | grep GPG
应该给出一些输出,例如GPG_AGENT_INFO=/tmp/gpg-6YivG1/S.gpg-agent:10479:1
。如果没有设置 GPG_AGENT_INFO 变量,您可能必须手动启动 gpg-agent 或(最好)将系统配置为自动启动 gpg-agent。如何执行此操作取决于您的发行版。 GnuPG 手册有一些关于此的信息。I think there are two ways to do this:
let
gpg
read the passphrase from a file using the option--passphrase-file
(but the gpg man page advises against using this option if you can avoid it! And i think you can avoid it as follows...);use
gpg-agent
for caching the passphrase. If the shell script requires you to enter the passphrase every time, there's likely no agent running. If a gpg-agent is running,env | grep GPG
should give some output likeGPG_AGENT_INFO=/tmp/gpg-6YivG1/S.gpg-agent:10479:1
. If there's no GPG_AGENT_INFO variable set, you may have to start gpg-agent manually or (preferable) configure your system to start the gpg-agent automatically. How to do this depends on your distribution. The GnuPG Manual has some infos about this.