ssh连接主机时,出现如下报错如何解决?

在客户端连接服务端:

  1. [root@86DA4B286450F420 ~]# ssh 10.50.12.3
  2. ssh_exchange_identification: read: Connection reset by peer
  3. [root@86DA4B286450F420 ~]#

-v表示查看连接详细信息

  1. [root@86DA4B286450F420 ~]# ssh -v 10.50.12.3
  2. OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
  3. debug1: Reading configuration data /etc/ssh/ssh_config
  4. debug1: /etc/ssh/ssh_config line 58: Applying options for *
  5. debug1: Connecting to 10.50.12.3 [10.50.12.3] port 22.
  6. debug1: Connection established.
  7. debug1: permanently_set_uid: 0/0
  8. debug1: key_load_public: No such file or directory
  9. debug1: identity file /root/.ssh/id_rsa type -1
  10. debug1: key_load_public: No such file or directory
  11. debug1: identity file /root/.ssh/id_rsa-cert type -1
  12. debug1: key_load_public: No such file or directory
  13. debug1: identity file /root/.ssh/id_dsa type -1
  14. debug1: key_load_public: No such file or directory
  15. debug1: identity file /root/.ssh/id_dsa-cert type -1
  16. debug1: key_load_public: No such file or directory
  17. debug1: identity file /root/.ssh/id_ecdsa type -1
  18. debug1: key_load_public: No such file or directory
  19. debug1: identity file /root/.ssh/id_ecdsa-cert type -1
  20. debug1: key_load_public: No such file or directory
  21. debug1: identity file /root/.ssh/id_ed25519 type -1
  22. debug1: key_load_public: No such file or directory
  23. debug1: identity file /root/.ssh/id_ed25519-cert type -1
  24. debug1: Enabling compatibility mode for protocol 2.0
  25. debug1: Local version string SSH-2.0-OpenSSH_7.4
  26. ssh_exchange_identification: read: Connection reset by peer
  27. [root@86DA4B286450F420 ~]#

解决方案:在服务端更改配置文件

  1. [root@0655019423330986 opt]# cat /etc/hosts.allow
  2. #
  3. # hosts.allow This file contains access rules which are used to
  4. # allow or deny connections to network services that
  5. # either use the tcp_wrappers library or that have been
  6. # started through a tcp_wrappers-enabled xinetd.
  7. #
  8. # See 'man 5 hosts_options' and 'man 5 hosts_access'
  9. # for information on rule syntax.
  10. # See 'man tcpd' for information on tcp_wrappers
  11. #
  12. sshd: ALL
  13. [root@0655019423330986 opt]#

重启sshd

  1. systemctl restart sshd