One possible solution to your problem is the work-around / hack that I am using at the time of writing. However, I am also searching for another easy solution.
I am using Windows 10 Pro Version 1903 Build 18362.418 and Ubuntu 18.04 in WSL.
I noticed that when ever I start 'ssh-agent' in WSL, a process of 'ssh-agent' is started in Windows 10.

The work-around / hack I am using is that I start 'ssh-agent' is WSL by using ssh-agent
, It gives me some output like
SSH_AUTH_SOCK=/tmp/ssh-4T3ZkVnWhIA7/agent.19; export SSH_AUTH_SOCK;
SSH_AGENT_PID=20; export SSH_AGENT_PID;
I copy these commands and paste / execute them in WSL to connect with 'ssh-agent' and then save these commands in a text file in windows 10.
I add keys to 'ssh-agent' in WSL as usual.
Whenever I open a new WSL session, I simple paste / execute these saved commands in New WSL session terminal and the new WSL session connects to already existing 'ssh-agent' process and I don't have to start a new 'ssh-agent' and add keys again.
EDIT 1:
Recently I used another work-around / hack. Instead of coping the output generated by ssh-agent
and then pasting the copied content to New WSL session terminal to use already started 'ssh agent'.
I performed these commands in first WSL session terminal.
ssh-agent > ssh_env
source ssh_env
and then if I needed New WSL session terminal, I just started it and used
source ssh_env
to connect with already started 'ssh agent'. This just reduced the steps of coping, saving and later using the output generated by ssh-agent
that I had mentioned before.
Hope this helps.
PS. I don't launch WSL from Windows 10 Command Prompt using wsl.exe
.
I usually open WSL form 'Start Menu'.
