Skip to content

Instantly share code, notes, and snippets.

@jiggneshhgohel
Last active September 8, 2022 00:28
Show Gist options
  • Save jiggneshhgohel/afe96f0d57bdbf8beba305a73905402d to your computer and use it in GitHub Desktop.
Save jiggneshhgohel/afe96f0d57bdbf8beba305a73905402d to your computer and use it in GitHub Desktop.
Windows 10 Linux Subsystem SSH-agent issues
Host github.com-jiggneshhgohel
HostName github.com
User git
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_work_gmail
AddKeysToAgent yes


Host csexperimental.abc.com
IdentityFile ~/.ssh/id_work_gmail
AddKeysToAgent yes

References:

FROM

$ ssh -V
OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8, OpenSSL 1.0.1f 6 Jan 2014

TO

~$ ssh -V
OpenSSH_7.3p1 Ubuntu-1, OpenSSL 1.0.2g  1 Mar 2016
@jiggneshhgohel
Copy link
Author

@zebralight You should follow the steps listed in answer https://stackoverflow.com/a/45562886/936494 and you should be through.

Hope that helps.

@o-be-one
Copy link

o-be-one commented Oct 6, 2017

Thanks a lot for your last link jiggnesh, it helped me to deal with it :).

@bahamas10
Copy link

bahamas10 commented Oct 18, 2017

I tried all of the solutions in this gist and the links provided but kept running into issues - mainly around my keys requiring passphrases so they can't be automatically added (without manual intervention). I wrote a post here http://daveeddy.com/2017/10/18/persistent-sshagent-on-bash-on-ubuntu-on-windows/ about how I solved the issue.

Long story short, I create a Windows login service that starts a hidden instance of bash that runs ssh-agent to keep it running so long as the computer is up. When you add a key to the agent (with or without a passphrase), it will stay in the agent and the agent will stay up so long as your user is logged into Windows.

All of the code for the scripts is on GitHub as well available under an open source license: https://github.com/bahamas10/windows-bash-ssh-agent

@ralphie02
Copy link

ralphie02 commented Jan 4, 2018

@jiggneshhgohel is this persistent on a workstation reboot?

@jiggneshhgohel
Copy link
Author

is this persistent on a workstation reboot?

@ralphie02 By explicitly stating workstation if you are referring to something special then sorry I cannot comment on it. But after doing the config shown in above steps and rebooting the machine the config is persistent.

@gomker
Copy link

gomker commented Jul 5, 2018

This method was not working for me with latest Ubuntu 18.04 and Windows 10
Errors connecting to SSH agent still occur

FYI - looks to be a bug

microsoft/WSL#3183

@ygale
Copy link

ygale commented Aug 30, 2018

According to the discussion in microsoft/WSL#3183, the issue with ssh-agent on Ubuntu 18.04 is fixed in insiders build 17704. The fix will be pushed out to regular Windows builds as part of the Fall 2018 update. In the meantime, one reported work-around is to retrieve the ssh-agent binary for Ubuntu 16.04 from the Ubuntu site and use that on 18.04 for now. In #3183 there is a recipe by @rcarmo how to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment