Using built-in SSH with Git on Windows 10

Starting with Windows 10 version 1803 a native version of OpenSSH is bundled and installed by default. If you are using posh-git you'll notice that the Start-SshAgent command fails with an error:

unable to start ssh-agent service, error :1058
Error connecting to agent: No such file or directory

This is because by default the OpenSSH agent (ssh-agent) service is disabled. To enable it, open an elevated PowerShell window and run:

Set-Service -StartupType Manual ssh-agent

Now Start-SshAgent will work as it always has, however by default Git (for Windows) will continue to use the bundled OpenSSH package. This means that you are now running an ssh-agent that Git will not use.

To fix this add the following to the Git config:

[core]
    sshCommand = C:/WINDOWS/System32/OpenSSH/ssh.exe

I generally use this command to edit the global Git config: git config --global -e.

Now Git will switch to the Windows supplied OpenSSH implementation, and everything works together nicely.

Update 29-01-2020: Removed quotes from Git config as these are not needed; added git config instructions.