获取 kex_exchange_identification:远程主机关闭了私人 gitlab 域的连接,可能是什么原因造成的?

获取 kex_exchange_identification:远程主机关闭了私人 gitlab 域的连接,可能是什么原因造成的?

我使用的是 Ubuntu 20.04.2 LTS,之所以这么说,是因为这个版本似乎存在加密问题。今天我创建了一个密钥,它可以完美地工作[电子邮件保护]但给出了kex_exchange_identification:远程主机关闭了私有 GitLab 域的连接 这是 .ssh 配置文件

Host gitlab.com
Hostname altssh.gitlab.com
User git
Port 443
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_ed25519

# Private GitLab instance
Host gitlab.ebpearls.com
Hostname gitlab.ebpearls.com
User git
Port 443
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_ed25519

这是完整的日志

ssh -Tvvv git@gitlab.<mycompanydomain>.com
OpenSSH_8.2p1 Ubuntu-4ubuntu0.3, OpenSSL 1.1.1f  31 Mar 2020
debug1: Reading configuration data /home/nabin/.ssh/config
debug1: /home/nabin/.ssh/config line 9: Applying options for gitlab.ebpearls.com
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug2: resolving "gitlab.ebpearls.com" port 443
debug2: ssh_connect_direct
debug1: Connecting to gitlab.ebpearls.com [mycompanyip] port 443.
debug1: Connection established.
debug1: identity file /home/nabin/.ssh/id_ed25519 type 3
debug1: identity file /home/nabin/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.3
debug1: kex_exchange_identification: banner line 0: HTTP/1.1 400 Bad Request
debug1: kex_exchange_identification: banner line 1: Server: nginx
debug1: kex_exchange_identification: banner line 2: Date: Wed, 06 Oct 2021 06:50:54 GMT
debug1: kex_exchange_identification: banner line 3: Content-Type: text/html
debug1: kex_exchange_identification: banner line 4: Content-Length: 150
debug1: kex_exchange_identification: banner line 5: Connection: close
debug1: kex_exchange_identification: banner line 6: 
debug1: kex_exchange_identification: banner line 7: <html>
debug1: kex_exchange_identification: banner line 8: <head><title>400 Bad Request</title></head>
debug1: kex_exchange_identification: banner line 9: <body>
debug1: kex_exchange_identification: banner line 10: <center><h1>400 Bad Request</h1></center>
debug1: kex_exchange_identification: banner line 11: <hr><center>nginx</center>
debug1: kex_exchange_identification: banner line 12: </body>
debug1: kex_exchange_identification: banner line 13: </html>
kex_exchange_identification: Connection closed by remot

答案1

这是因为私有 gitlab repo 不允许从 443 进行 ssh,而 ISP 不允许使用 22 端口进行 ssh。对于那些允许 443 的私有 repo,此解决方案将起作用。我应该寻找一些跳转服务器解决方案,我可以使用中间跳转服务器的 443 端口,然后从那里 ssh 到目标服务器的 22 端口。

相关内容