diff options
author | gwjo <gowen72@gmail.com> | 2010-09-24 20:46:52 -0400 |
---|---|---|
committer | gwjo <gowen72@gmail.com> | 2010-09-24 20:46:52 -0400 |
commit | 62cea310fb97a98f6360397dfeef3a01507153fd (patch) | |
tree | 10fe247569910ba55ed4c9c25766e1e3c5cf0b96 /plugins/ssh-agent.plugin.zsh | |
parent | 99f159e0a7c63e6756f8e6e40691914da8f7a96c (diff) | |
download | zsh-62cea310fb97a98f6360397dfeef3a01507153fd.tar.gz zsh-62cea310fb97a98f6360397dfeef3a01507153fd.tar.bz2 zsh-62cea310fb97a98f6360397dfeef3a01507153fd.zip |
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.
Diffstat (limited to 'plugins/ssh-agent.plugin.zsh')
-rw-r--r-- | plugins/ssh-agent.plugin.zsh | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/plugins/ssh-agent.plugin.zsh b/plugins/ssh-agent.plugin.zsh new file mode 100644 index 000000000..fa8c45ea2 --- /dev/null +++ b/plugins/ssh-agent.plugin.zsh @@ -0,0 +1,24 @@ +# Based on code from Joseph M. Reagle +# http://www.cygwin.com/ml/cygwin/2001-06/msg00537.html + +local SSH_ENV=$HOME/.ssh/environment + +function start_agent { + /usr/bin/ssh-agent | sed 's/^echo/#echo/' > ${SSH_ENV} + chmod 600 ${SSH_ENV} + . ${SSH_ENV} > /dev/null + /usr/bin/ssh-add; +} + +# Source SSH settings, if applicable + +if [ -f "${SSH_ENV}" ]; then + . ${SSH_ENV} > /dev/null + #ps ${SSH_AGENT_PID} doesn't work under cywgin + ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || { + start_agent; + } +else + start_agent; +fi + |