简体   繁体   English

错误:无法运行 ssh:尝试在 windows 上克隆时没有此类文件或目录

[英]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 :在这些情况下,您可能会遇到此错误:

  • You use a URL like this : git@github.com:organization/repo.git你使用这样的 URL: git@github.com:organization/repo.git
  • And you run a kind of command like this directly : 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 客户端(或者它不在路径上)
  • 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或者您安装了 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,所以,

  • If you do not have ssh client, first of all, you need to install it如果没有ssh客户端,首先需要安装
  • 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 密钥设置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:症状:

  • SSH seems properly installed SSH 似乎已正确安装
  • SSH can be run from command line without problem SSH 可以毫无问题地从命令行运行

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.

相关问题 Windows版Git,将GIT_SSH设置为外壳文件会导致“错误:无法生成 <path> : 没有相应的文件和目录” - Git for Windows, setting GIT_SSH to a shell file causes causes “error: cannot spawn <path>: No such file or directory” 错误:尝试在 Windows 上克隆 Sapper 项目时路径无效 - Error: invalid path when trying to clone a Sapper project on Windows 无法从Windows服务器克隆GIT存储库,但可以进行SSH - Cannot Clone GIT Repository from windows server but can SSH 如何解决错误oci运行时错误:exec:在Windows上使用docker运行时,没有此类文件或目录 - How can I resolve the error oci runtime error: exec: no such file or directory when using docker run on Windows 尝试对凭据进行授权时出错:UserWarning:无法访问token.json:没有此类文件或目录 - Getting error when trying to authorize credentials.json: UserWarning: Cannot access token.json: No such file or directory 当我尝试运行从Windows系统编写的Linux脚本时出现“无此文件或目录”错误 - “No such file or directory” error when I try to run a Linux script written from Windows system Windows “以管理员身份运行”时的批处理文件起始目录 - Windows batch file starting directory when 'run as admin' 尝试在 MS Windows 上运行时出现“mlflow ui”错误 - Error with “mlflow ui” when trying to run it on MS Windows Windows 命令行 - 尝试在同一行中运行 2 个命令时出错 - Windows command line - error when trying to run 2 command in the same line 尝试使用NSSM将可执行文件.jar作为Windows服务运行时出错 - Error when trying to run an executable .jar as a Windows service using NSSM
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM