Linux – ssh-agent reset in Windows Subsystem for linux (WSL)

linuxsshssh-agentwindows 10windows-subsystem-for-linux

I am trying to use ssh-agent under WSL but the SSH params are wiped after the script is run

From .bashrc (cut down version)

eval $(ssh-agent)
ssh-add

ssh-add -l
echo "SSH_AGENT_PID is" $SSH_AGENT_PID
echo "SSH_AUTH_SOCK is" $SSH_AUTH_SOCK

Prompts for the passphrase then shows the fingerprint and relevant variables

straight after at prompt (or seperate script) running

ssh-add -l
echo "SSH_AGENT_PID is" $SSH_AGENT_PID
echo "SSH_AUTH_SOCK is" $SSH_AUTH_SOCK

gives

Could not open a connection to your authentication agent.
SSH_AGENT_PID is
SSH_AUTH_SOCK is

(tidied for readability)

the agent is still running with the original pid (checked in top)
also tried eval $(ssh-agent ) > /dev/null and eval $(ssh-agent -s) and in combination

Why do these get wiped? ssh-agent worked fine until windows update 1709 "fall creators update"

for info:
linux version 4.4.0-43-Microsoft (Microsoft@Microsoft.com) (gcc version 5.4.0 (GCC) ) #1-Microsoft Wed Dec 31 14:42:53 PST 2014

Best Answer

I'm copying the answer given in another similar thread (https://stackoverflow.com/a/50942800/9966057).

It's no use trying to tweak your session setup.

Full answer : https://github.com/Microsoft/WSL/issues/3183

Short version : ssh-agent forwarding is broken by a getsockopt bug in wsl / ubuntu 18.04 (or any other linux I would imagine).

Related Question