I am running OpenSSH on Windows, using the built-in OpenSSH included since the Autumn/Fall Creators Update.
I am using ssh just fine in my PowerShell, but Visual Studio Remote Development (and I guess Git for Windows?) are not using my OpenSSH. Instead, they seem to be using the Git for Windows SSH client from MinGW. This means all my ssh-add
ed keys are not present in the VS or Git ssh-agent
.
How can I get Visual Studio (and maybe Git?) to use the builtin OpenSSH install so that I can use the same ssh-agent
between them all?
Here is what SSH looks like in PowerShell:
c:\Users\myusername
> Get-Command ssh
CommandType Name Version Source
----------- ---- ------- ------
Application ssh.exe 7.7.2.1 C:\WINDOWS\System32\OpenSSH\ssh.exe
c:\Users\myusername
> Get-Command ssh-agent
CommandType Name Version Source
----------- ---- ------- ------
Application ssh-agent.exe 7.7.2.1 C:\WINDOWS\System32\OpenSSH\ssh-agent.exe
C:\Users\myusername
> Get-Command ssh-add
CommandType Name Version Source
----------- ---- ------- ------
Application ssh-add.exe 7.7.2.1 C:\WINDOWS\System32\OpenSSH\ssh-add.exe
c:\Users\myusername
> ssh-add -l
2048 SHA256:HASH_HERE C:\Users\myusername\.ssh\id_rsa (RSA)
myusername@COMPUTERNAME MINGW64 ~
$ which ssh
/usr/bin/ssh
myusername@COMPUTERNAME MINGW64 ~
$ which ssh-agent
/usr/bin/ssh-agent
myusername@COMPUTERNAME MINGW64 ~
$ which ssh-add
/usr/bin/ssh-add
myusername@COMPUTERNAME MINGW64 ~
$ ssh-add -l
Could not open a connection to your authentication agent.
I am using VS Code Remote Development. Every time I log in to my remote computer, I am prompted for my private key's password.
Without private key auth, I am prompted for my logon password (for the remote user).
VS Code works most easily with SSH keys without a passphrase. To use SSH Git authentication with VS Code, you have launch VS Code from a Git Bash prompt to inherit its SSH environment.
Using the OpenSSH client included in Windows 10 (1809) as your Git's SSH client. Microsoft has included an OpenSSH client with Windows 10 since the Fall Creators Release (1709). This client has been installed by default since the April 2018 Update (1803).
This is a known issue/regression with VS Code Remote Development.
The workaround is simple: change VS Code's SSH path.
remote.SSH.path
.C:\Windows\System32\OpenSSH\ssh.exe
(or C:\\Windows\\System32\\OpenSSH\\ssh.exe
if editing JSON).VS Code will now use the OpenSSH ssh-agent
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With