add ssh-agent option to set default lifetime of identities
By default, ssh-agent stores identities forever. It has an option to
set a maximum lifetime for identites (useful to expire passphrase protected
keys). Allow this option to be set using:
zstyle :omz:plugins:ssh-agent lifetime <time>
Diff
1diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh
2index c4e92a1fe00403782e7eacbb0fb5009b5f65629a..7468749f8b9c2d1395d4d4c0a7a51e09d2b74c7e 100644
3--- a/plugins/ssh-agent/ssh-agent.plugin.zsh
4+++ b/plugins/ssh-agent/ssh-agent.plugin.zsh
5@@ -6,11 +6,17 @@
6 #
7 # zstyle :omz:plugins:ssh-agent agent-forwarding on
8 #
9-# To load multiple identies use the identities style, For
10+# To load multiple identities use the identities style, For
11 # example:
12 #
13 # zstyle :omz:plugins:ssh-agent id_rsa id_rsa2 id_github
14 #
15+# To set the maximum lifetime of the identities, use the
16+# lifetime style. The lifetime may be specified in seconds
17+# or as described in sshd_config(5) (see TIME FORMATS)
18+# If left unspecified, the default lifetime is forever.
19+#
20+# zstyle :omz:plugins:ssh-agent lifetime 4h
21 #
22 # CREDITS
23 #
24@@ -27,15 +33,18 @@ local _plugin__forwarding
25 function _plugin__start_agent()
26 {
27 local -a identities
28+ local lifetime
29+ zstyle -s :omz:plugins:ssh-agent lifetime lifetime
3031 # start ssh-agent and setup environment
32- /usr/bin/env ssh-agent | sed 's/^echo/#echo/' > ${_plugin__ssh_env}
33+ /usr/bin/env ssh-agent ${lifetime:+-t} ${lifetime} | sed 's/^echo/#echo/' > ${_plugin__ssh_env}
34 chmod 600 ${_plugin__ssh_env}
35 . ${_plugin__ssh_env} > /dev/null
3637 # load identies
38 zstyle -a :omz:plugins:ssh-agent identities identities
39- echo starting...
40+ echo starting ssh-agent...
41+
42 /usr/bin/ssh-add $HOME/.ssh/${^identities}
43 }
44