aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-05-18 00:24:50 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2020-05-18 00:27:33 +0300
commita95626f568680577fee7cec19d8ff6cc65bbd8da (patch)
tree92b7767cc2f85693f63c1cca3c11b035ffc4eded
parent.profile: setup chruby (diff)
downloadlinux-home-a95626f568680577fee7cec19d8ff6cc65bbd8da.tar.gz
linux-home-a95626f568680577fee7cec19d8ff6cc65bbd8da.zip
.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.
-rw-r--r--%HOME%/.profile2
1 files changed, 1 insertions, 1 deletions
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 \