从 gitlab 克隆 repo 的问题(致命:远程端意外挂断)

Posted

技术标签:

【中文标题】从 gitlab 克隆 repo 的问题(致命:远程端意外挂断)【英文标题】:Issue with cloning repo from gitlab (fatal: The remote end hung up unexpectedly) 【发布时间】:2013-07-31 12:26:57 【问题描述】:

制作时:

sudo git clone git@gitlab.mydomain.com:ws.git

我收到一个错误:

> sudo git clone git@gitlab.mydomain.com:root/ws.git
Password:
Cloning into 'ws'…
The authenticity of host 'gitlab.mydomain.com (x.x.x.x)' can't be established.
RSA key fingerprint is xx:xx:xx…xx:xx.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'gitlab.mydomain.com,x.x.x.x' (RSA) to the list of known hosts.
git@gitlab.mydomain.com's password: 
Permission denied, please try again.
git@gitlab.mydomain.com's password: 
fatal: 'root/ws.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

即使我改变了网址:

> sudo git clone git@gitlab.mydomain.com:ws.git
Password:
Cloning into 'ws'…
git@gitlab.mydomain.com's password: 
fatal: 'ws.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

有什么问题?

公共克隆有问题吗?我只能克隆添加个人 ssh 密钥吗?

更新:

添加了个人 ssh-key:

现在:

ssh -Tvvv root@gitlab.mydomain.com
OpenSSH_5.6p1, OpenSSL 0.9.8x 10 May 2012
debug1: Reading configuration data /Users/user/.ssh/config
debug1: Applying options for gitlab.mydomain.com
debug1: Reading configuration data /etc/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to gitlab.mydomain.com[x.x.x.x] port 22.
debug1: Connection established.
debug3: Not a RSA1 key file /Users/user/.ssh/root_gitlab.mydomain.com.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: missing keytype
debug2: key_type_from_name: unknown key type 'Proc-Type:'
debug3: key_read: missing keytype
debug2: key_type_from_name: unknown key type 'DEK-Info:'
debug3: key_read: missing keytype
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug2: key_type_from_name: unknown key type '-----END'
debug3: key_read: missing keytype
debug1: identity file /Users/user/.ssh/root_gitlab.mydomain.com.de type 1
debug1: identity file /Users/user/.ssh/root_gitlab.mydomain.com-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.0p1 Debian-4
debug1: match: OpenSSH_6.0p1 Debian-4 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.6
debug2: fd 3 setting O_NONBLOCK
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ssh-rsa-cert-v00@openssh.com,ssh-dss-cert-v00@openssh.com,ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: kex_parse_kexinit: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: mac_setup: found hmac-md5
debug1: kex: server->client aes128-ctr hmac-md5 none
debug2: mac_setup: found hmac-md5
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug2: dh_gen_key: priv key bits set: 119/256
debug2: bits set: 499/1024
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug3: check_host_in_hostfile: host gitlab.mydomain.com filename /Users/user/.ssh/known_hosts
debug3: check_host_in_hostfile: host gitlab.mydomain.com filename /Users/user/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 43
debug3: check_host_in_hostfile: host x.x.x.x filename /Users/user/.ssh/known_hosts
debug3: check_host_in_hostfile: host x.x.x.x filename /Users/user/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 38
debug1: Host 'gitlab.mydomain.com' is known and matches the RSA host key.
debug1: Found key in /Users/user/.ssh/known_hosts:43
debug2: bits set: 511/1024
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /Users/user/.ssh/id_rsa (0x105725350)
debug2: key: /Users/user/.ssh/root_gitlab.mydomain.com (0x105724510)
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/user/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: /Users/user/.ssh/root_gitlab.mydomain.com
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
root@gitlab.mydomain.com's password:

有什么问题?

更新2:

这个 [SSH Key asks for password] 不起作用

更新3:

> sudo git clone --verbose git@gitlab.mydomain.com:ws.git
Cloning into 'ws'...
fatal: The remote end hung up unexpectedly

【问题讨论】:

它不应该要求您输入密码。 ssh -Tvvv git@gitlab.mydomain.com 有效吗? 这不会解决你的命令行问题,但我发现使用 TortoiseGit 修复了命令行返回的错误。尽管如此,我还是按照与命令相同的顺序选择选项。 您是如何生成 SSH 密钥对的?看起来它正在客户端读取损坏的私钥,也许您使用现有密钥的复制/粘贴手动创建了一个并且它破坏了格式? @static 你为什么要做ssh root@gitlab.mydomain.com?不应该是git而不是root吗? :ssh git@gitlab.mydomain.com @static 你有一个``/Users/user/.ssh/config` 文件吗?如果是,它的内容是什么? 【参考方案1】:

我正是遇到了这个问题,只是通过反复试验才设法找到答案。

> sudo git clone --verbose git@gitlab.mydomain.com:ws.git
Cloning into 'ws'...
fatal: The remote end hung up unexpectedly

原来 gitlab 不喜欢 2048 位 SSH 密钥。我将 SSH 密钥更改为 4096 位,它工作正常。我不知道这是 sshd 配置的结果还是什么,但这对我有用。

【讨论】:

【参考方案2】:

从这里找到解决方案gitlabhq issue on github:

查看您的 puma 或 unicorn 服务器配置:

sudo nano /home/git/gitlab/config/puma.rb

在那里阅读一个绑定的 url(有趣的是端口 - 在我的例子中是 9292// 我将绑定变体从 unix 管道更改为 http://0.0.0.0:9292 前一段时间)

适当更改 gitlab-shell 中的 config.yml:

sudo nano /home/git/gitlab-shell/config.yml

重启gitlab服务:

sudo 服务 gitlab 重启

(不知道,不过我也重启了apache:sudo service apache2 restart

完成:

现在,只需从项目页面复制 url 并执行以下操作:

git clone your-gitlab-url

【讨论】:

听起来更好,然后:) 无论如何,有趣的是不要混淆用于 ssh 的 unix 用户帐户和通过 Web 界面管理 git repo 的 gitlab 帐户。 是的,这个建议当然很好。对于这种情况,您是否知道任何最佳做法,也许适用于所有其他平台? 我的意思是对于任何其他平台? :) 主要将安装gitlab的账号与管理账号(如root)区别开来

以上是关于从 gitlab 克隆 repo 的问题(致命:远程端意外挂断)的主要内容,如果未能解决你的问题,请参考以下文章

克隆 git repo 导致错误 - 主机密钥验证失败。致命:远端意外挂断

怎么从gitlab中克隆分支代码

错误:未找到存储库。致命:无法从远程存储库中读取。请确保您拥有正确的访问权限并且 repo 存在

如何在 gitlab 中的 git clone 后包含文件

使用Visual Studio 2017克隆TFS Git repo时出错400

接收失败:连接已重置 git