[英]error: cannot run ssh: No such file or directory when trying to clone on windows
I am trying to clone a remote repository on Windows, but when I did this:我正在尝试在 Windows 上克隆一个远程存储库,但是当我这样做时:
git clone git@github.com:organization/xxx.git
I got this error:我收到此错误:
error: cannot run ssh: No such file or directory
fatal: unable to fork
Am I missing something?我错过了什么吗?
Check if you have installed ssh-client
.检查您是否已安装ssh-client
。 This solve the problem on docker machines, even when ssh keys are present:这解决了 docker 机器上的问题,即使存在 ssh 密钥:
apt-get install ssh-client
You don't have ssh installed (or don't have it within your search path).您没有安装 ssh(或者您的搜索路径中没有安装它)。
You can clone from github via http, too:您也可以通过 http 从 github 克隆:
git clone http://github.com/organization/xxx
Most likely your GIT_SSH_COMMAND
is referencing the incorrect public key.很可能您的GIT_SSH_COMMAND
引用了不正确的公钥。
Try:尝试:
export GIT_SSH_COMMAND="ssh -i /home/murphyslaw/.ssh/your-key.id_rsa
then然后
git clone git@github.com:organization/xxx.git
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 :在这些情况下,您可能会遇到此错误:
git@github.com:organization/repo.git
你使用这样的 URL: git@github.com:organization/repo.git
git clone git@github.com/xxxxx.git
whereas you don't have ssh client (or it is not present on path)你直接运行这样的命令: git clone git@github.com/xxxxx.git
而你没有 ssh 客户端(或者它不在路径上)git clone xxx.git
work fine on direct command line) but when you run the same kind of command through a shell script file或者您安装了 ssh 客户端(并且git clone xxx.git
在直接命令行上工作正常)但是当您通过 shell 脚本文件运行相同类型的命令时Here, I assume that you don't want to change protocol ssh git@
to http://
( git@github.com:organization/repo.git
-> http://github.com/organization/repo.git
), like my case, cause I needed the ssh
format.在这里,我假设您不想将协议ssh git@
更改为http://
( git@github.com:organization/repo.git
-> http://github.com/organization/repo.git
),就像我的情况,因为我需要ssh
格式。
So,所以,
GIT_SSH_COMMAND
variable with your public ssh key, in front of your git command, like this :如果仅在通过脚本执行时出现此错误,则需要在 git 命令前面使用公共 ssh 密钥设置GIT_SSH_COMMAND
变量,如下所示:
GIT_SSH_COMMAND="/usr/bin/ssh -i ~/.ssh/id_rsa" git pull
(Feel free to change it depending on your context) (根据您的情况随意更改它)
I had this issue right after my antivirus moved the cygwin ssh binary to virus vault, and restored it after.在我的防病毒软件将 cygwin ssh 二进制文件移动到病毒库后,我立即遇到了这个问题,并在之后将其恢复。
Symptoms:症状:
Another option before reinstalling ssh in this particular case: check the ssh
command permissions在这种特殊情况下重新安装 ssh 之前的另一个选择:检查ssh
命令权限
$ ls -al /usr/bin/ssh.exe
----rwxrwx+
$ chmod 770 /usr/bin/ssh.exe
You can try these as well你也可以试试这些
ssh-add ~/.ssh/identity_file
chmod 400 ~/.ssh/identity_file
It so happened in my case that the new pair of ssh keys linked with my git account were not accessible.在我的案例中,与我的 git 帐户关联的一对新的 ssh 密钥无法访问。
I had to sudo chmod 777 ~/.ssh/id_rsa.*
to resolve the issue.我不得不sudo chmod 777 ~/.ssh/id_rsa.*
来解决这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.