gitlab服务: kex_exchange_identification: Connection closed by remote host

搜索了一圈,其实是基本原理没理解到位。

git clone git@xxx.com:group/project.git实际使用的是SSH协议。多个认证文件存在时,通常需要在config文件中进行类似如下的配置——

需要强调的是:Port端口值是SSH服务的端口,只有在SSH服务的默认端口变更是才需要进行显示配置

Host github.com
# Specifies the real host name to log into. Numeric IP addresses are also permitted.
HostName github.com
# Defines the username for the SSH connection.
User gebitang
# Specifies a file from which the user’s DSA, ECDSA or DSA authentication identity is read.
IdentityFile ~/.ssh/id_rsa
Host prj.geb.cn
HostName prj.geb.cn
# Specifies the port number to connect on the remote host. only if the port for ssh connection is not 22.
Port 8201
# The default is ~/.ssh/identity for protocol version 1, and ~/.ssh/id_dsa, ~/.ssh/id_ecdsa and ~/.ssh/id_rsa for protocol version 2.
IdentityFile ~/.ssh/geb_id_rsa
自己搭建的环境使用的路由器自带的DMZ功能(路由器下的内网中的某台机器作为路由器绑定的静态ip的服务提供商。简单理解为——此静态ip提供的所有服务实际上都来自某台指定的内网机器)

搭建的gitlab服务使用的web服务端口是9527,而不是默认的80端口。使用http地址进行git操作时,提供用户名、密码可以正常进行操作。添加了ed25519格式的SSH key后,一直提示kex_exchange_identification: Connection closed by remote host的错误。执行ssh -vT git@stf.geb-corp.com测试时,提示如下详细信息。配置生效了,

from Mac

~ ssh -vT git@stf.geb-corp.com
OpenSSH_8.1p1, LibreSSL 2.7.3
debug1: Reading configuration data /Users/gebitang/.ssh/config
debug1: /Users/gebitang/.ssh/config line 15: Applying options for stf.geb-corp.com
debug1: /Users/gebitang/.ssh/config line 28: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 47: Applying options for *
debug1: Connecting to stf.geb-corp.com port 9527.
debug1: Connection established.
debug1: identity file /Users/gebitang/.ssh/id_ed25519 type 3
debug1: identity file /Users/gebitang/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.1
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: Tue, 27 Apr 2021 07:36:29 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:
debug1: kex_exchange_identification: banner line 8: 400 Bad Request
debug1: kex_exchange_identification: banner line 9:
debug1: kex_exchange_identification: banner line 10:

400 Bad Request


debug1: kex_exchange_identification: banner line 11:
nginx

debug1: kex_exchange_identification: banner line 12:
debug1: kex_exchange_identification: banner line 13:
kex_exchange_identification: Connection closed by remote host

from Windows

joechin@Gebitang MINGW64 /e/0daywork
$ ssh -vT git@stf.geb-corp.com
OpenSSH_7.7p1, OpenSSL 1.0.2o 27 Mar 2018
debug1: Reading configuration data /c/Users/joechin/.ssh/config
debug1: /c/Users/joechin/.ssh/config line 8: Applying options for stf.geb-corp.com
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to stf.geb-corp.com [10.112.78.174] port 9527.
debug1: Connection established.
debug1: identity file /c/Users/joechin/.ssh/id_ed25519 type 3
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/joechin/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.7
debug1: ssh_exchange_identification: HTTP/1.1 400 Bad Request
debug1: ssh_exchange_identification: Server: nginx
debug1: ssh_exchange_identification: Date: Tue, 27 Apr 2021 08:11:51 GMT
debug1: ssh_exchange_identification: Content-Type: text/html
debug1: ssh_exchange_identification: Content-Length: 150
debug1: ssh_exchange_identification: Connection: close
debug1: ssh_exchange_identification:
debug1: ssh_exchange_identification:
debug1: ssh_exchange_identification: 400 Bad Request
debug1: ssh_exchange_identification:
debug1: ssh_exchange_identification:

400 Bad Request


debug1: ssh_exchange_identification:
nginx

debug1: ssh_exchange_identification:
debug1: ssh_exchange_identification:
ssh_exchange_identification: Connection closed by remote host
可以在nginx的log下看到10.115.8.73 - - [27/Apr/2021:16:00:41 +0800] “- -” 400 150 “” "-"这样的信息。

实际上就只是端口配置错误了而已~~

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值