Question

SSH error: Connection closed by host port 22

I got this error when trying to connect to the server using ssh

$ ssh -vvv user@ip OpenSSH_7.4p1, LibreSSL 2.5.0 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 20: Applying options for * debug2: resolving “128.199.240.57” port 22 debug2: ssh_connect_direct: needpriv 0 debug1: Connecting to 128.199.240.57 [128.199.240.57] port 22. debug1: Connection established. debug1: identity file /Users/{myusername]/.ssh/id_rsa type 1 debug1: key_load_public: No such file or directory debug1: identity file /Users//{myusername]/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users//{myusername]/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users//{myusername]/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users//{myusername]/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users//{myusername]/.ssh/id_ecdsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users//{myusername]/.ssh/id_ed25519 type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users//{myusername]/.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.2p2 Ubuntu-4ubuntu2.2 debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.2 pat OpenSSH* compat 0x04000000 debug2: fd 3 setting O_NONBLOCK debug1: Authenticating to 128.199.240.57:22 as ‘/{myusername]’ debug3: hostkeys_foreach: reading file “/Users//{myusername]/.ssh/known_hosts” debug3: record_hostkey: found key type ECDSA in file /Users//{myusername]/.ssh/known_hosts:4 debug3: load_hostkeys: loaded 1 keys from 128.199.240.57 debug3: order_hostkeyalgs: prefer hostkeyalgs: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521 debug3: send packet: type 20 debug1: SSH2_MSG_KEXINIT sent Connection closed by 128.199.240.57 port 22

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hello, all

You can use the -vvv argument in the ssh command in order to get more verbose output.

Another thing to check is our tutorial on How to Connect to Droplets with SSH

https://docs.digitalocean.com/products/droplets/how-to/connect-with-ssh/

Regards, Alex

Try to rebuild your droplet. Helped for me.