zsh:z{profile,logout}: Kill only 'own' ssh-agent
Kill the ssh-agent only if it was created in this session. Like that the login shell can inherit SSH_AGENT_PID without it killing the agent at the end. For this to work properly it is important that LAUNCHED_SSH_AGENT is not exported, otherwise nested login shells will mess with each other.
This commit is contained in:
@@ -1 +1,2 @@
|
||||
[[ -z $SSH_AGENT_PID ]] || kill "$SSH_AGENT_PID"
|
||||
# Kill ssh-agent if it was created in this session
|
||||
! (( LAUNCHED_SSH_AGENT && SSH_AGENT_PID )) || kill "$SSH_AGENT_PID"
|
||||
|
||||
@@ -48,6 +48,8 @@ fi
|
||||
# SSH
|
||||
if (( $+commands[ssh-agent] )) && [[ ! $SSH_AGENT_PID ]]; then
|
||||
eval "$(ssh-agent)" >/dev/null
|
||||
# See .zlogout
|
||||
LAUNCHED_SSH_AGENT=1
|
||||
fi
|
||||
|
||||
# Editor
|
||||
|
||||
Reference in New Issue
Block a user