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:
- https://stackoverflow.com/a/45562886/936494 - summarizes everything listed in this gist in form of steps which can be followed to resolve SSH agent issues.
- https://superuser.com/questions/1238486/windows-10-linux-subsystem-ssh-agent-not-persisting-added-identities#1238595 - This is the original post which details the issue I was facing
- https://unix.stackexchange.com/questions/269121/openssh-have-ssh-add-keys-to-agent-as-needed
- https://stackoverflow.com/a/41555393/936494 - This one I used to upgrade my SSH version
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
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