通过 ssh 从远程存储库 :fatal: protocol error: bad line length character: fata 进行 git 克隆

标签 git ssh msysgit git-clone

我已经在 Windows 8 机器上设置了一个 git 服务器,如下所示

  • msysgit(在客户端和服务器上)
  • FreeSSHd(在服务器上)

git安装时

  • 在服务器(windows 8)上我选择安装目录为 d:\Experiments\Git
  • 在客户端(windows 7)上,我选择它是默认的,即 ProgramFiles(x86)

Have setup proper public and private key and copied perivate key from server to client machine

我可以使用 ssh 命令通过 SSH 连接到我的服务器

$ ssh UserOne@192.168.1.4
Enter passphrase for key '/c/Users/UserOne/.ssh/id_rsa':
UserOne@192.168.1.4's password:

上面的结果是

Microsoft Windows [Version 6.2.9200]
(c) 2012 Microsoft Corporation. All rights reserved.

C:\Users\Gaurav\Desktop>

但是当我尝试 git clone 我的远程存储库时出现错误...以下是我执行的命令以及执行后的结果

$ git clone ssh://UserOne@192.168.1.4/d/Experiments/repo/CenRepo /d/Experiments/Playground/New
Cloning into 'd:/Experiments/Playground/New'...
Enter passphrase for key '/c/Users/UserOne/.ssh/id_rsa':
UserOne@192.168.1.4's password:
fatal: protocol error: bad line length character: fata

我在一些文章中看到执行 git-receive-pack,如果有任何路径问题,它实际上会输出错误..但它运行良好..以下是命令及其结果。

$ ssh UserOne@192.168.1.4 git-receive-pack d:/Experiments/repo/CenRepo
Enter passphrase for key '/c/Users/UserOne/.ssh/id_rsa':
UserOne@192.168.1.4's password:
00900000000000000000000000000000000000000000 capabilities^{}  report-status delete-refs side-band-64k quiet ofs-delta agent=git/1.8.3.msysgit.00000

请注意我输入的是“d:/Experiments/repo/CenRepo”而不是“/d/Experiments/repo/CenRepo”

我不能在 git clone 命令中写“d:/Experiments/repo/CenRepo”

我是 git 的新手,所以不太了解它。谢谢

最佳答案

fatal: protocol error: bad line length character: fat

请参阅此常见问题解答:

It likely means you have some extraneous characters, info message or something upon logging into ssh in command mode.

To test this, do:

 ssh user@git.example.com echo testing commands

(在你的情况下:)

ssh UserOne@192.168.1.4 echo testing commands

You should only see 'testing commands' returned.
If there are any other characters, you should examine your dot shell rc file to find any echo or other commands that may produce output.

对于 FreeSSHd,您应该检查它是否可以在不返回任何额外输出的情况下执行命令。

This answer建议可能无法配置 FreeSSHd 以使其“安静”(执行并返回所需命令的输出,无需额外数据)。
它建议使用替代的 ssh 守护进程。

关于通过 ssh 从远程存储库 :fatal: protocol error: bad line length character: fata 进行 git 克隆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17296348/

相关文章:

Gitolite:添加用户不起作用,并且在克隆为 root 时被 fallthru 拒绝?

windows - 由于 "SSL protocol"错误,Windows 上的 Git 无法使用远程

Git - fork 或不 fork

git - 将 "git git"别名为 "git"?

Linux:通过 ssh 连接自动传输 sftp 文件

linux - Git - SSH - 主机 : How can I delegate different IPs to remote origin, 取决于每次工作的内容?

Gitolite 一个用户 - 许多键 - 不同的用户名

git - 执行 git 深度扫描以比较文件的真实性

git gui 分支管理

GIT SSH连接问题