Remove stale ssh-agent socket
This commit is contained in:
parent
7f0ce4c79c
commit
e026154a3a
1 changed files with 8 additions and 0 deletions
|
@ -240,6 +240,14 @@ if command -v ssh-agent > /dev/null
|
|||
then
|
||||
export SSH_AUTH_SOCK="${SSH_AUTH_SOCK:-$XDG_RUNTIME_DIR/ssh-agent.socket}"
|
||||
export SSH_AGENT_PID="${SSH_AGENT_PID:-$XDG_RUNTIME_DIR/ssh-agent.pid}"
|
||||
ssh-add -l > /dev/null 2>&1
|
||||
local _acp_ssh_agent_exists=$?
|
||||
if [ -S "$SSH_AUTH_SOCK" ] && [ $_acp_ssh_agent_exists -eq 2 ]
|
||||
then
|
||||
# Remove stale ssh-agent socket.
|
||||
rm -f "$SSH_AUTH_SOCK"
|
||||
fi
|
||||
unset _acp_ssh_agent_exists
|
||||
if [ ! -S "$SSH_AUTH_SOCK" ]
|
||||
then
|
||||
ssh-agent -a "$SSH_AUTH_SOCK" > /dev/null
|
||||
|
|
Loading…
Reference in a new issue