SSH error: Connection closed by host port 22

September 20, 2017 11.4k views
Nginx Ubuntu 16.04

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

$ ssh -vvv user@ip
OpenSSH7.4p1, LibreSSL 2.5.0
debug1: Reading configuration data /etc/ssh/ssh
config
debug1: /etc/ssh/sshconfig line 20: Applying options for *
debug2: resolving “128.199.240.57” port 22
debug2: ssh
connectdirect: 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: keyloadpublic: No such file or directory
debug1: identity file /Users//{myusername]/.ssh/idrsa-cert type -1
debug1: key
loadpublic: No such file or directory
debug1: identity file /Users//{myusername]/.ssh/id
dsa type -1
debug1: keyloadpublic: No such file or directory
debug1: identity file /Users//{myusername]/.ssh/iddsa-cert type -1
debug1: key
loadpublic: No such file or directory
debug1: identity file /Users//{myusername]/.ssh/id
ecdsa type -1
debug1: keyloadpublic: No such file or directory
debug1: identity file /Users//{myusername]/.ssh/idecdsa-cert type -1
debug1: key
loadpublic: No such file or directory
debug1: identity file /Users//{myusername]/.ssh/id
ed25519 type -1
debug1: keyloadpublic: No such file or directory
debug1: identity file /Users//{myusername]/.ssh/ided25519-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 OpenSSH7.2p2 Ubuntu-4ubuntu2.2
debug1: match: OpenSSH
7.2p2 Ubuntu-4ubuntu2.2 pat OpenSSH* compat 0x04000000
debug2: fd 3 setting ONONBLOCK
debug1: Authenticating to 128.199.240.57:22 as ’/{myusername]’
debug3: hostkeys
foreach: reading file “/Users//{myusername]/.ssh/knownhosts”
debug3: record
hostkey: found key type ECDSA in file /Users//{myusername]/.ssh/knownhosts:4
debug3: load
hostkeys: loaded 1 keys from 128.199.240.57
debug3: orderhostkeyalgs: 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

1 Answer

Try to rebuild your droplet. Helped for me.

Have another answer? Share your knowledge.

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