Note: Use this only as your last resort, and only if you also have a firewall protecting your server, this is dangerous to apply, and if you do, try to go back to the previous (default) configuration as soon as possible.

When trying to connect via ssh to a server, I got this answer from the server.

ssh_exchange_identification: Connection closed by remote host

If this happens to you too, first start looking if you are using this format to log in the server

ssh -l [existing-server-user ] [ip-of-the-server]

or

ssh [existing-server-user]@[ip-of-the-server]

Then, and here it was my problem, be sure you have correctly set your

/etc/hosts.allow and /etc/hosts.deny

mine was

hosts.allow

#
# /etc/hosts.allow
#

# End of file

which was O.K.

hosts.deny

#
# /etc/hosts.deny
#

ALL: ALL: DENY

# End of file

So it was denying me the access to any port of the server, as soon as I comment the ALL: ALL: DENY line it start working, keep in mind that any change to these files can compromise your server’s security, so be careful.