62cea310fb97a98f6360397dfeef3a01507153fd
Author gwjo <gowen72@gmail.com> Committer gwjo <gowen72@gmail.com> Date 2010-09-25 00:46 UTC
Message ssh-agent module
Implement a simple module that automatically launches the ssh-agent when you login and
adds your default key.
Useful for anyone that does remote work and thus doesn't have access to a keychain tool.
Diff 1 diff --git a/plugins/ssh-agent.plugin.zsh b/plugins/ssh-agent.plugin.zsh
2 new file mode 100644
3 index 0000000000000000000000000000000000000000..fa8c45ea2217b8daff13529ccbc0ab7da87b18c5
4 --- /dev/null
5 +++ b/plugins/ssh-agent.plugin.zsh
6 @@ -0,0 +1,24 @@
7 +# Based on code from Joseph M. Reagle
8 +# http://www.cygwin.com/ml/cygwin/2001-06/msg00537.html
9 +
10 +local SSH_ENV=$HOME/.ssh/environment
11 +
12 +function start_agent {
13 + /usr/bin/ssh-agent | sed 's/^echo/#echo/' > ${SSH_ENV}
14 + chmod 600 ${SSH_ENV}
15 + . ${SSH_ENV} > /dev/null
16 + /usr/bin/ssh-add;
17 +}
18 +
19 +# Source SSH settings, if applicable
20 +
21 +if [ -f "${SSH_ENV}" ]; then
22 + . ${SSH_ENV} > /dev/null
23 + #ps ${SSH_AGENT_PID} doesn't work under cywgin
24 + ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
25 + start_agent;
26 + }
27 +else
28 + start_agent;
29 +fi
30 +