ssh-agent
非常易于使用,我启动它并使用ssh-add keyfile
. 杀死进程后ssh-agent
,所有文件都消失了。
我怎样才能得到相同的行为gpg-agent
?我找到的最接近的程序是gpg-preset-passphrase
. 但是查看 的手册页gpg-agent
,似乎创建了一个用于存储私钥的目录。
我可能是错的,所以我想知道如何gpg-agent
以不创建文件/目录的方式进行设置?如果不可能,也欢迎其他gpg-agent
像ssh-agent
+ssh-add
这样工作的建议。我不是在寻找像 Seahorse 这样的 GUI 解决方案。
Lek*_*eyn 13
我决定再看看这个,并了解它是如何工作的。GPG 使用术语“缓存”来存储密码。可以对最大存储时间施加两个约束:
此外,两种约束都存在两种变体,一种用于 GPG 密钥,一种用于 SSH 密钥(如果启用了支持)。
相关手册页条目来自gpg-agent(1)
:
--default-cache-ttl n
Set the time a cache entry is valid to n seconds. The default
is 600 seconds.
--default-cache-ttl-ssh n
Set the time a cache entry used for SSH keys is valid to n sec?
onds. The default is 1800 seconds.
--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. The default is 2 hours (7200 seconds).
--max-cache-ttl-ssh n
Set the maximum time a cache entry used for SSH keys is valid to
n seconds. After this time a cache entry will be expired even
if it has been accessed recently. The default is 2 hours (7200
seconds).
Run Code Online (Sandbox Code Playgroud)
密码总是被缓存(在内存中,而不是在磁盘上!使用 的 git repo 进行验证$HOME
),因此没有明确需要ssh-add
. 例如,签署虚拟数据已经触发了缓存:
$ echo | gpg -s >/dev/null
(passphrase requested
$ echo | gpg -s >/dev/null
(signing proceeds without asking for passphrase)
Run Code Online (Sandbox Code Playgroud)
要永久更改 gpg-agent 的缓存设置,请编辑 ~/.gnupg/gpg-agent.conf` 并添加如下内容:
default-cache-ttl 60 # Expire GPG keys when unused for 1 minute
max-cache-ttl 600 # Expire GPG keys after 10 minutes since addition
Run Code Online (Sandbox Code Playgroud)
我试图通过指定启用 SSH 代理支持enable-ssh-support
,但这会使 gpg-agent 要求您提供另一个密钥来加密密钥,然后将您的私钥存储在~/.gnupg/private-keys.d/
. 不适合我,然后我会坚持使用双 ssh-agent / gpg-agent 方法。
一些奖金提示:
max-cache-ttl-ssh
添加密钥时可以指定SSH代理的等效项,例如:ssh-add -t 600 ~/.ssh/id_rsa
要防止在代理中存储 GPG 密码,请禁用代理。在较新的 GPG 版本中,该选项--no-use-agent
被忽略,但您可以通过清除相关的环境变量来防止使用代理。这样做的一些方法:
echo | GPG_AGENT_INFO= gpg -s # temporary
export GPG_AGENT_INFO=; echo | gpg -s # until the current shell is closed
Run Code Online (Sandbox Code Playgroud) 归档时间: |
|
查看次数: |
12661 次 |
最近记录: |