error: cannot run ssh: No such file or directory when trying to clone on windows

WindowsGitGit Clone

Windows Problem Overview


I am trying to clone a remote repository on Windows, but when I did this:

git clone [email protected]:organization/xxx.git

I got this error:

error: cannot run ssh: No such file or directory
fatal: unable to fork

Am I missing something?

Windows Solutions


Solution 1 - Windows

Check if you have installed ssh-client. This solves the problem on docker machines, even when ssh keys are present:

apt-get install openssh-client

Solution 2 - Windows

You don't have ssh installed (or don't have it within your search path).

You can clone from github via http, too:

git clone http://github.com/organization/xxx

Solution 3 - Windows

Most likely your GIT_SSH_COMMAND is referencing the incorrect public key.

Try:

export GIT_SSH_COMMAND="ssh -i /home/murphyslaw/.ssh/your-key.id_rsa

then

git clone [email protected]:organization/xxx.git

Solution 4 - Windows

I am aware that it is an old topic, but having this problem recently, I want to bring here what I resolve my issue.


You might have this error on these conditions :

  • You use a URL like this : [email protected]:organization/repo.git
  • And you run a kind of command like this directly : git clone [email protected]/xxxxx.git whereas you don't have ssh client (or it is not present on path)
  • Or you have an ssh client installed (and git clone xxx.git work fine on direct command line) but when you run the same kind of command through a shell script file

Here, I assume that you don't want to change protocol ssh git@ to http:// ([email protected]:organization/repo.git -> http://github.com/organization/repo.git), like my case, cause I needed the ssh format.


So,

  • If you do not have ssh client, first of all, you need to install it
  • If you have this error only when you execute it through a script, then you need to set GIT_SSH_COMMAND variable with your public ssh key, in front of your git command, like this :

> GIT_SSH_COMMAND="/usr/bin/ssh -i ~/.ssh/id_rsa" git pull

(Feel free to change it depending on your context)

Solution 5 - Windows

I had this issue right after my antivirus moved the cygwin ssh binary to virus vault, and restored it after.

Symptoms:

  • SSH seems properly installed
  • SSH can be run from command line without problem

Another option before reinstalling ssh in this particular case: check the ssh command permissions

$ ls -al /usr/bin/ssh.exe
----rwxrwx+
$ chmod 770 /usr/bin/ssh.exe

Solution 6 - Windows

You can try these as well

ssh-add ~/.ssh/identity_file
chmod 400 ~/.ssh/identity_file

Solution 7 - Windows

It so happened in my case that the new pair of ssh keys linked with my git account were not accessible.

I had to sudo chmod 777 ~/.ssh/id_rsa.* to resolve the issue.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMallocView Question on Stackoverflow
Solution 1 - WindowspablorskView Answer on Stackoverflow
Solution 2 - WindowsMarkView Answer on Stackoverflow
Solution 3 - WindowsrivanovView Answer on Stackoverflow
Solution 4 - WindowsMahefaView Answer on Stackoverflow
Solution 5 - Windowsuser1556814View Answer on Stackoverflow
Solution 6 - WindowsAbdul Muiz KhanView Answer on Stackoverflow
Solution 7 - WindowsDota2View Answer on Stackoverflow