summaryrefslogtreecommitdiff
path: root/plugins/ssh-agent
diff options
context:
space:
mode:
authorMarc Cornellà <hello@mcornella.com>2021-06-14 10:57:50 +0200
committerMarc Cornellà <hello@mcornella.com>2021-06-14 10:57:50 +0200
commit3e7998aec33ff7551d06d4510f9e8769aab5db93 (patch)
tree2015d5a14240415e5cc72272e2bcbb283e94190b /plugins/ssh-agent
parent77087aaa8d9ff92ef84ae727411f0eca100ed5de (diff)
downloadzsh-3e7998aec33ff7551d06d4510f9e8769aab5db93.tar.gz
zsh-3e7998aec33ff7551d06d4510f9e8769aab5db93.tar.bz2
zsh-3e7998aec33ff7551d06d4510f9e8769aab5db93.zip
Revert "ssh-agent: improvements (#6309)"
This reverts commit a206271460ce49e842b1b410c0424b8c9a0a3d14.
Diffstat (limited to 'plugins/ssh-agent')
-rw-r--r--plugins/ssh-agent/README.md12
-rw-r--r--plugins/ssh-agent/ssh-agent.plugin.zsh29
2 files changed, 10 insertions, 31 deletions
diff --git a/plugins/ssh-agent/README.md b/plugins/ssh-agent/README.md
index aa96f9cc9..8765a9c7e 100644
--- a/plugins/ssh-agent/README.md
+++ b/plugins/ssh-agent/README.md
@@ -19,17 +19,9 @@ To enable **agent forwarding support** add the following to your zshrc file:
zstyle :omz:plugins:ssh-agent agent-forwarding on
```
-To **NOT load any identities on start** use the `lazy` style.
-This is particularly usefull when combined with the AddKeysToAgent
-(available from OpenSSH 7.2), since it allows to enter the password only
-on first use.
-
-```zsh
-zstyle :omz:plugins:ssh-agent lazy yes
-```
+----
-To **load multiple identities** use the `identities` style. This have no
-effect if `lazy` is enabled.
+To **load multiple identities** use the `identities` style, For example:
```zsh
zstyle :omz:plugins:ssh-agent identities id_rsa id_rsa2 id_github
diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh
index 494cf1393..d45406f63 100644
--- a/plugins/ssh-agent/ssh-agent.plugin.zsh
+++ b/plugins/ssh-agent/ssh-agent.plugin.zsh
@@ -1,16 +1,4 @@
-lockdir=/tmp/oh-my-zsh-ssh-agent.lock
-
-while true; do
- if mkdir "$lockdir" 2>/dev/null
- then # directory did not exist, but was created successfully
- trap 'rm -rf "$lockdir"' 0 # remove directory when script finishes
- break # continue with script
- else
- sleep 0.1 # sleep for 0.2 and try again
- fi
-done
-
-typeset _ssh_env_cache
+typeset _agent_forwarding _ssh_env_cache
function _start_agent() {
local lifetime
@@ -68,7 +56,10 @@ function _add_identities() {
# Get the filename to store/lookup the environment from
_ssh_env_cache="$HOME/.ssh/environment-$SHORT_HOST"
-if zstyle -t :omz:plugins:ssh-agent agent-forwarding && [[ -n "$SSH_AUTH_SOCK" ]]; then
+# test if agent-forwarding is enabled
+zstyle -b :omz:plugins:ssh-agent agent-forwarding _agent_forwarding
+
+if [[ $_agent_forwarding == "yes" && -n "$SSH_AUTH_SOCK" ]]; then
# Add a nifty symlink for screen/tmux if agent forwarding
[[ -L $SSH_AUTH_SOCK ]] || ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USERNAME-screen
elif [[ -f "$_ssh_env_cache" ]]; then
@@ -82,16 +73,12 @@ elif [[ -f "$_ssh_env_cache" ]]; then
ps $FILTER | grep ssh-agent | grep -q $SSH_AGENT_PID || {
_start_agent
}
-elif [[ -d $HOME/.ssh ]]; then
+else
_start_agent
fi
-if ! zstyle -t :omz:plugins:ssh-agent lazy; then
- _add_identities
-fi
+_add_identities
# tidy up after ourselves
-unset _ssh_env_cache
+unset _agent_forwarding _ssh_env_cache
unfunction _start_agent _add_identities
-
-rm -rf "$lockdir"