In .bash_logout, do clearing and killing seperately.
This commit is contained in:
parent
dc550c2d59
commit
eb17e766ef
1 changed files with 13 additions and 7 deletions
20
.bash_logout
20
.bash_logout
|
@ -13,9 +13,9 @@ if (( $SHLVL == 10 )); then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove the SSH_AUTH_SOCK from the agents file.
|
hash ssh-add ssh-agent >/dev/null 2>&1 && {
|
||||||
(( $SHLVL == 1 )) && {
|
# Remove the SSH_AUTH_SOCK from the agents file.
|
||||||
hash ssh-add ssh-agent >/dev/null 2>&1 && [[ ! -z "$SSH_AGENT_PID" ]] && [[ ! -z "$SSH_AUTH_SOCK" ]] && {
|
[[ ! -z "$SSH_AUTH_SOCK" ]] && {
|
||||||
exec 9>~/.ssh/agents.lock
|
exec 9>~/.ssh/agents.lock
|
||||||
if flock -E 10 -w 0.5 9; then
|
if flock -E 10 -w 0.5 9; then
|
||||||
_pop_agent_sock || {
|
_pop_agent_sock || {
|
||||||
|
@ -27,10 +27,16 @@ fi
|
||||||
_SLEEP=3
|
_SLEEP=3
|
||||||
fi
|
fi
|
||||||
exec 9>&-
|
exec 9>&-
|
||||||
ssh-agent -k >/dev/null 2>&1 || {
|
}
|
||||||
echo -e "$(tput setaf 1 || tput AF 1)Failed to kill ssh-agent!$(tput op)"
|
|
||||||
_SLEEP=3
|
# Kill the ssh-agent.
|
||||||
|
(( $SHLVL == 1 )) && {
|
||||||
|
[[ ! -z "$SSH_AGENT_PID" ]] && {
|
||||||
|
ssh-agent -k >/dev/null 2>&1 || {
|
||||||
|
echo -e "$(tput setaf 1 || tput AF 1)Failed to kill ssh-agent!$(tput op)"
|
||||||
|
_SLEEP=3
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sleep ${_SLEEP:-0}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sleep ${_SLEEP:-0}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue