Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ssh上的git守护程序-致命:协议错误:错误的行长度字符:ssh-_Git_Ssh_Git Daemon - Fatal编程技术网

ssh上的git守护程序-致命:协议错误:错误的行长度字符:ssh-

ssh上的git守护程序-致命:协议错误:错误的行长度字符:ssh-,git,ssh,git-daemon,Git,Ssh,Git Daemon,我在服务器端创建了用户“gitproxy”,将我的ssh密钥添加到其授权密钥中,并尝试通过ssh使用git守护进程: gitproxy:~$ git daemon --port=2222 --verbose 但是有一个错误: 在客户端: o:~/git$ git clone ssh://server>:2222/home/gitproxy/git Cloning into 'git'... ssh: connect to host <server> port 2222: Co

我在服务器端创建了用户“gitproxy”,将我的ssh密钥添加到其授权密钥中,并尝试通过ssh使用git守护进程:

gitproxy:~$ git daemon --port=2222 --verbose
但是有一个错误: 在客户端:

o:~/git$ git clone ssh://server>:2222/home/gitproxy/git
Cloning into 'git'...
ssh: connect to host <server> port 2222: Connection refused
fatal: Could not read from remote repository.
$ ssh gitproxy@192.168.201.84  git-receive-pack  /home/gitproxy/git
008fef8bbf80818e6b634ca56c3ef6c24e5bbdb7bf74 refs/heads/masterreport-status delete-refs side-band-64k quiet atomic ofs-delta agent=git/2.16.1
0046ef8bbf80818e6b634ca56c3ef6c24e5bbdb7bf74 refs/remotes/origin/HEAD
0048ef8bbf80818e6b634ca56c3ef6c24e5bbdb7bf74 refs/remotes/origin/master
回购协议是存在的。另外,我通常通过SSH进入此服务器,而不使用密码(因此,我的SSH密钥被接受):

此外,我还可以从我的桌面(客户端)获取git receive pack的分支列表:

我检查了stackoverflow上提出的所有可能的修复方案。但是git守护进程仍然返回错误。 我将非常感谢您的帮助。提前谢谢

不讲SSH协议,讲简单的git协议;协议的URL必须以
git://
开头,而不是
ssh://
。即,您服务器的URL为
git://192.168.201.84:2222/


要通过ssh使用git repo,您需要一个ssh服务器。看来你有一个:至少gitproxy@192.168.201.84; 好的,那么回购协议的URL是
ssh://gitproxy@192.168.201.84/home/gitproxy/git
。同一URL的另一种“类似scp”的语法是
gitproxy@192.168.201.84:git

git守护进程是一个实现
git
协议的服务器,即与
git://...
URL。它不理解SSH协议,因此当您理解时:

git克隆ssh://:2222/home/gitproxy/git

您正试图通过SSH协议连接到
:2222
(由于
ssh://...
URL)。然后,
git守护进程不理解SSH发送给它的内容(错误消息中的
SSH-
是初始SSH握手的一部分)

如果您实际上打算使用SSH协议与远程存储库进行交互,则根本不需要使用
git守护进程。通过使用
ssh://...
URL表单,git命令将使用SSH调用所需的远程命令(例如手动执行的
receive-pack
)。在这种情况下,只需删除URL的端口规范,然后退出服务器上的
git守护进程。身份验证和加密由SSH作为传输机制提供,授权使用文件系统权限完成

如果您确实想使用
git守护进程
git
协议,请将URL改为
git://:2222/…
。请注意,
git
协议不提供任何身份验证、加密或授权机制,公开的存储库将完全公开

但是我需要
--git守护进程的
-accesshook
(或者在客户端运行“gitpull”时执行某些操作的任何其他机制)

然后,只使用SSH(一个完全没有git的守护进程),您就可以使用

在~gitproxy/.ssh/authorized_密钥中,您可以调用任何要执行操作的脚本,然后使用
$ssh_ORIGINAL_命令
(其中包括“
Git upload pack | Git receive pack | Git upload archive”
Git命令)调用Git本身


您甚至可以自行安装,因为它将为您管理授权部分。

非常感谢。但我需要--git守护进程的访问钩子(或在客户端运行“git pull”时执行某些操作的任何其他机制)。@Alexander Great!别忘了阅读
$ ssh gitproxy@192.168.201.84
gitproxy@192.168.201.84:~$
$ ssh gitproxy@192.168.201.84  git-receive-pack  /home/gitproxy/git
008fef8bbf80818e6b634ca56c3ef6c24e5bbdb7bf74 refs/heads/masterreport-status delete-refs side-band-64k quiet atomic ofs-delta agent=git/2.16.1
0046ef8bbf80818e6b634ca56c3ef6c24e5bbdb7bf74 refs/remotes/origin/HEAD
0048ef8bbf80818e6b634ca56c3ef6c24e5bbdb7bf74 refs/remotes/origin/master