连接服务端的gitlab时出现ssh_exchange_identification: read: Connection reset by peer

问题由来:

本机执行git push时出现ssh_exchange_identification: read: Connection reset by peer fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

进行ssh调试:

gg@DESKTOP-STOOSVR MINGW64 ~/Desktop
$ ssh -v git@118.25.6.666
OpenSSH_7.9p1, OpenSSL 1.1.1a  20 Nov 2018
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to 118.25.6.666 [118.25.6.666] port 22.
debug1: Connection established.
debug1: identity file /c/Users/gg/.ssh/id_rsa type 0
debug1: identity file /c/Users/gg/.ssh/id_rsa-cert type -1
debug1: identity file /c/Users/gg/.ssh/id_dsa type -1
debug1: identity file /c/Users/gg/.ssh/id_dsa-cert type -1
debug1: identity file /c/Users/gg/.ssh/id_ecdsa type -1
debug1: identity file /c/Users/gg/.ssh/id_ecdsa-cert type -1
debug1: identity file /c/Users/gg/.ssh/id_ed25519 type -1
debug1: identity file /c/Users/gg/.ssh/id_ed25519-cert type -1
debug1: identity file /c/Users/gg/.ssh/id_xmss type -1
debug1: identity file /c/Users/gg/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9
ssh_exchange_identification: read: Connection reset by peer

百思不得其姐,显示能够与之通信但是被拒绝连接,研究了好几秒恍然大悟,自己以前对可通过ssh连接的ip进行了限制,使用时的ip不在通行列表,导致ssh连接被拒绝,解决此问题很简单:
1、在/etc/hosts.allow中添加对外ip(公网的那种,百度搜ip会显示出来的那个)

[root@VM_0_13_centos ~]# vim /etc/hosts.allow 
sshd:106.66.*.*,107.7.*.*:allow  # 示例ip

或者直接在hosts.allow 键入sshd:ALL # 不限制可通过ssh登录的ip

2、重启sshd

[root@VM_0_13_centos ~]# /bin/systemctl restart sshd.service
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值