Unable to use git in WSL. C:\Windows\System32\OpenSSH\ssh.exe: not found

Viewed 1585

So im on Windows 10 and a while ago i decided to use WSL so the I can get zsh. However, now I can no long use git from my wsl terminal, i.e I can no longer git pull from remote repo. When I try I get the following...

'C:\Windows\System32\OpenSSH\ssh.exe': 1: C:\Windows\System32\OpenSSH\ssh.exe: not found
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Such operations work fine in bash and from GitHub Desktop. Why is WSL trying to use OpenSSH from Windows it should be Linux right?

Im struggling to find information on this problem so any help is greatly appreciated. Let me know if there is more information I can provide.

2 Answers

I got the same error after changing the value "core.sshCommand" like this:

git config --global core.sshCommand "'C:\Windows\System32\OpenSSH\ssh.exe'"

In my file ~/.gitconfig, I disabled newlines like below :

#[core]
#       sshCommand = 'C:\\Windows\\System32\\OpenSSH\\ssh.exe'

Then when you are in a git repository, if you have the same problem check your my-project/.git/config file and if there is the new config disable it as above.

In my case it worked :-)
Have a nice day

Double check if you have an environment variable GIT_SSH which would point to C:\Windows\System32\OpenSSH\ssh.exe: that would not be a valid path in a WSL session.

Unset it.
After that, it depends on the Windows 10 used ( 1709? 1809? 20H1? ...), and on the WSL used (WSL1 or WSL2?).

Related