From a95626f568680577fee7cec19d8ff6cc65bbd8da Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Mon, 18 May 2020 00:24:50 +0300 Subject: .profile: fix spawn_ssh_agent I recently had to deal with a system that doesn't have systemd (Alpine), and it used this "deprecated" way of launching ssh-agent. It didn't work with agent forwarding though: the local agent would be launched regardless, somehow overriding the forwarded agent. This is fixed by testing if SSH_AUTH_SOCK (instead of SSH_AGENT_PID) is defined, and it is defined for agent-forwarded ssh sessions. It remains to be seen how this interacts with systems that use the systemd unit to launch ssh-agent. --- %HOME%/.profile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '%HOME%') diff --git a/%HOME%/.profile b/%HOME%/.profile index c382ae2..ccb1f92 100644 --- a/%HOME%/.profile +++ b/%HOME%/.profile @@ -84,7 +84,7 @@ kill_ssh_agent() { spawn_ssh_agent() { local output - [ -z "${SSH_AGENT_PID:+x}" ] \ + [ -z "${SSH_AUTH_SOCK:+x}" ] \ && command -v ssh-agent > /dev/null 2>&1 \ && output="$( ssh-agent -s )" \ && eval "$output" > /dev/null \ -- cgit v1.2.3