Solve the problem of "ssh_exchange_identification: Connection closed by remote host" or Connection refused when ssh connects to a remote machine

Many people have encountered the problem of ssh_exchange_identification: Connection closed by remote host when connecting to a remote machine with ssh . I found a bunch of tutorials on the Internet and tried it, but it didn’t work. The blogger summed up several common solutions (all local machine operation ).

  • Possible reason 1 : openssh-server is not installed ; solution:

    sudo apt install openssh-server
    

    or

    sudo apt-get install openssh-server
    
  • Possible reason 2 : The connection exceeds the MaxSessions limit; solution: modify sudo gedit /etc/ssh/sshd_config, # MaxSessions 10cancel the comment in and 10change to50

  • Possible reason 3 : ip is denied; solution: check separately /var/log/denyhosts, /etc/hosts.denyand usr/share/denyhosts/data/hosts/whether there is an intercepted ip record in and, if so, add your ip to it /etc/hosts.allow.

Guess you like

Origin blog.csdn.net/lyh458/article/details/107834282