解决ssh_exchange_identification:read connection reset by peer 原因

这篇具有很好参考价值的文章主要介绍了解决ssh_exchange_identification:read connection reset by peer 原因。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

服务器改了密码,试过密码多次后出现:

1
ssh_exchange_identification: read: Connection reset by peer

可以通过ssh -v查看连接时详情

OpenSSH_6.6.1, OpenSSL 1.0.1k-fips 8 Jan 2015
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 56: Applying options for *
debug1: Connecting to xxx [xx] port 22.
debug1: Connection established.
debug1: identity file /home/yanue/.ssh/id_rsa type -1
debug1: identity file /home/yanue/.ssh/id_rsa-cert type -1
debug1: identity file /home/yanue/.ssh/id_dsa type -1
debug1: identity file /home/yanue/.ssh/id_dsa-cert type -1
debug1: identity file /home/yanue/.ssh/id_ecdsa type -1
debug1: identity file /home/yanue/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/yanue/.ssh/id_ed25519 type -1
debug1: identity file /home/yanue/.ssh/id_ed25519-cert type -1

最后找打解决方法:

vi /etc/hosts.allow

追加:

1
sshd: ALL

ssh_exchange_identification: read: connection reset by peer,liunx,ssh,服务器,运维

重启ssh就ok了

1
service sshd restart

报错信息:
 ssh_exchange_identification: read: Connection reset by peer

[root@test2 ~]# ssh root@192.168.2.128
ssh_exchange_identification: read: Connection reset by peer

报错分析:
 -v:表示查看连接的详细信息

[root@test2 ~]# ssh -v root@192.168.2.128
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: Connecting to 192.168.2.128 [192.168.2.128] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
ssh_exchange_identification: read: Connection reset by peer

解决方法:
1.在要连接的主机128上修改配置文件

[root@localhost ~]# vim /etc/hosts.allow

sshd:ALL //允许其他所有ip主机连接本机

[root@localhost ~]# systemctl restart sshd

提醒:
 若是要限制只有某些IP地址可以连接该主机,则在/etc/hosts.allow文件中添加允许的主机IP(如:sshd:192.168.2.130:allow),然后再到/etc/hosts.deny文件中添加“sshd:ALL”拒绝所有(除了/etc/hosts.allow文件中允许的IP地址)就可以达到除了设置允许的IP地址可以连接,其他的IP主机都无法连接的效果。

相关博客: 基于Linux下限制指定用户或IP地址通过SSH登录(访问控制)

2.重新尝试连接128主机

[root@test2 ~]# ssh root@192.168.2.128
Last login: Thu Jun 18 11:42:17 2020 from gateway

[root@localhost ~]# ifconfig ens37
ens37: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.2.128 netmask 255.255.255.0 broadcast 192.168.2.255
inet6 fe80::58f3:f0e0:999e:dc3c prefixlen 64 scopeid 0x20
ether 00:0c:29:48:a1:65 txqueuelen 1000 (Ethernet)
RX packets 6671316 bytes 1274253678 (1.1 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 7124037 bytes 3235376682 (3.0 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

3.查看ssh成功连接的详细信息

登录后复制
[root@test2 ~]# ssh -v root@192.168.2.128
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: Connecting to 192.168.2.128 [192.168.2.128] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: match: OpenSSH_7.4 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 192.168.2.128:22 as ‘root’
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: compression: none
debug1: kex: curve25519-sha256 need=64 dh_need=64
debug1: kex: curve25519-sha256 need=64 dh_need=64
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:NPzH2XoAuBsa8cuKFIaVQRxHPXTsq397mZklQiPanAw
debug1: Host ‘192.168.2.128’ is known and matches the ECDSA host key.
debug1: Found key in /root/.ssh/known_hosts:9
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available (default cache: KEYRING:persistent:0)

debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available (default cache: KEYRING:persistent:0)

debug1: Next authentication method: publickey
debug1: Offering RSA public key: /root/.ssh/id_rsa
debug1: Server accepts key: pkalg rsa-sha2-512 blen 279
debug1: Authentication succeeded (publickey).
Authenticated to 192.168.2.128 ([192.168.2.128]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug1: Sending environment.
debug1: Sending env LANG = zh_CN.UTF-8
Last login: Thu Jun 18 13:33:49 2020 from 192.168.2.129

2、调整SSH配置文件中的连接数限制

出现SSH远程登录服务器失败,也可能是由于SSH连接数被限制了,导致无法连接。通常情况下SSH配置文件中的MaxStartups默认值是10,您可以运行下面命令查看连接数。

$ cat /etc/ssh/sshd_config | grep MaxStartups

增加SSH连接数
ssh_exchange_identification: read: connection reset by peer,liunx,ssh,服务器,运维

如果默认值不能达到要求,您可以将属性设置为更高的值。

3、安装缺少的依赖

如果缺少SSH服务所需的依赖项或库时,也会出现SSH远程登录服务器失败。在这种情况下,您可以考虑修复 Ubuntu / Debian 系统上显示的任何损坏的软件包。

$ sudo apt-get upgrade -f

对于 RHEL / CentOS 系统,只需升级系统即可。

$ sudo yum update文章来源地址https://www.toymoban.com/news/detail-809550.html

到了这里,关于解决ssh_exchange_identification:read connection reset by peer 原因的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 【已解决】kex_exchange_identification: Connection closed by remote host fatal: Could not read from

    报错代码 成功效果图 必要的解决方法 如果平时没有什么特别操作的话,换个网络就可以了,换个无线或者切换手机热点,实在不行等下再弄。不用去搞这个那个的配置。 可能有用的解决方法 可能需要把代理关了,没开代理的忽略

    2024年02月11日
    浏览(42)
  • git报错——kex_exchange_identification: read: Software caused connection abort banner exchange......

    1、问题: 在IDE推送的时候,出现了如下的问题,特此记录一下: kex_exchange_identification: read: Software caused connection abort banner exchange: Connection to 175.24.250.178 port 22: Software caused connection abort fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository

    2024年02月11日
    浏览(42)
  • 解决ssh:connect to host github.com port 22: Connection timed out与kex_exchange_identification

    无法进行clone项目和其他Git操作。执行检测连接命令 ssh -T git@github,com 报错 ssh:connect to host github.com port 22: Connection timed out 即:连接22端口超时 涉及到的文件 : C:UsersJIACHENGER.sshconfig C:UsersJIACHENGER.sshgithub_id_rsa C:UsersJIACHENGER.sshgithub_id_rsa.pub C:UsersJIACHENGER.sshknown_hosts 生成

    2024年02月06日
    浏览(50)
  • ssh报错:kex_exchange_identification

    今年回校之后发现ssh登录服务器会概率性出现 kex_exchange_identification 的错误。根据博文可知是ssh连接数量过多。进而猜测有肉鸡服务器尝试进行ssh爆破。 通过命令 cat /var/log/auth.log |more 可以发现大量校园内网IP正在撞库爆破。 按照博文的方案将允许的sshd连接数改为2000发现虽然

    2024年02月13日
    浏览(36)
  • github上传文件遇到错误:kex_exchange_identification: read: Software caused connection abort banner exchange:

    github上传文件时,连接不上ssh,输入ssh -T git@github.com,检查连接,出现以下错误: kex_exchange_identification: read: Software caused connection abort banner exchange: Connection to 20.205.243.166 port 22: Software caused connection abort 其中20.205.243.166是github的地址,22号端口是和你连接的端口。这段话意思是

    2024年02月10日
    浏览(44)
  • ssh登陆概率性失败,报错:kex_exchange_identification

    kex_exchange_identification: Connection closed by remote host 通过内网主机或者远程主机ssh登陆概率性失败,最高登陆失败率达到80%左右。 内网win主机登陆表现为登陆失败,需要反复登陆多次,因为这台主机是我内网的集中管控服务器,不能轻易的重装或者调整,整个大内网都靠它去监控

    2024年02月05日
    浏览(41)
  • ssh 连接出现错误: kex_exchange_identification: Connection closed by remote host

    错误如下表示: windstorm@LocalHost-Server ~ ssh webase-front@192.168.122.22 Couldn\\\'t get a file descriptor referring to the console. fish: Unknown command: nc fish: exec nc -X connect -x 127.0.0.1:15732 192.168.122.22 22      ^^ kex_exchange_identification: Connection closed by remote host 当出现这种错误的时候,不要慌,我在csdn上面

    2024年02月09日
    浏览(40)
  • ssh远程登录报错:kex_exchange_identification: Connection closed by remote host

    系统: MacOS Catalina 10.15.7 报错信息: 终端登录远程 服务器 时报错: 复制 然而服务商的一键登录或VNC登录正常。 首先使用以下命令debug登录过程,以便定位问题: 复制 如果你从此时返回的信息中能够发现大量的提示都指向: 复制 基本上能够确定问题出现在本机的配置上。

    2024年01月17日
    浏览(55)
  • SSH远程连接报错:kex_exchange_identification: Connection closed by remote host

    kex_exchange_identification: Connection closed by remote host 删除known_hosts,重启终端即可

    2024年02月11日
    浏览(46)
  • SSH远程连接时报错kex_exchange_identification: Connection closed by remote host

    在 SSH 服务器上进行远程内容时,会经常出现 kex_exchange_identification: Connection closed by remote host 内容,主要是由于远程计算机登录节点的数量限制问题。 在 SSH 服务器上,最大并发登录会话数是由 ‘MaxSessions’ 参数来控制的。 ‘MaxSessions’ 参数决定了 ssh 服务器最多会话数限制

    2024年02月16日
    浏览(46)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包