I got an "Error connecting to agent" error when attaching to an old
screen session the other day, but didn't find a good article on how to fix it, when searching with both phase of "Error connecting to agent" and "screen". So I decided to write about it so the next person knows how to fix such problem in the future.
The solution is quite simple, actually, and here is exactly how to do it.
- Before attaching to the old
- After attaching to the old
echo "$SSH_AUTH_SOCK"again. You should see that the values are different in the two cases.
SSH_AUTH_SOCKwith the correct value, which is the one before attaching to
That should fix the
Error connecting to agent problem.
# after logged into remote host, $ echo "$SSH_AUTH_SOCK" /tmp/ssh-2HsGhzu77S/agent.125711 # attaching to the old `screen` session screen -r old_session # get into screen $ echo "$SSH_AUTH_SOCK" /tmp/ssh-vosa42Ualz/agent.22985 $ ssh-add -l Error connecting to agent: No such file or directory # The SSH_AUTH_SOCK is no longer there. Point to the new one SSH_AUTH_SOCK=/tmp/ssh-2HsGhzu77S/agent.125711
Now, verify with another
ssh-add -l, which shall now output what it was before attaching to the old
The cover image is obtained from TechRepublic.