A
A
Alexander Leonchik2018-06-02 18:48:10
linux
Alexander Leonchik, 2018-06-02 18:48:10

How to fix ssh_exchange_identification error?

I have 3 machines, of which 2 are MacOS and Linux. Connecting to AWS Amazon EC2.
One machine with a freshly installed poppy on board gives an error:
ssh_exchange_identification: Connection closed by remote host
, the other two connect without any problems. I tried to copy the folder with .ssh from another poppy where everything is fine, the problem is the same. I don’t even know what else to think of, below are all the logs and configs that might help. There is no ban on the server.

➜ ~ ssh [email protected] -v
OpenSSH_7.6p1, LibreSSL 2.6.2
debug1: Reading configuration data /Users/man/.ssh/config
debug1: /Users/man/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: Connecting to IP port 22.
debug1: Connection established.
debug1: identity file /Users/man/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file /Users/man/.ssh/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6
ssh_exchange_identification: read: Connection reset by peer

sshd_config and ssh_config are default, but I'll attach them just in case
/etc/ssh/ssh_config
#       $OpenBSD: ssh_config,v 1.33 2017/05/07 23:12:57 djm Exp $

# This is the ssh client system-wide configuration file.  See
# ssh_config(5) for more information.  This file provides defaults for
# users, and the values can be changed in per-user configuration files
# or on the command line.

# Configuration data is parsed as follows:
#  1. command line options
#  2. user-specific file
#  3. system-wide file
# Any configuration value is only changed the first time it is set.
# Thus, host-specific definitions should be at the beginning of the
# configuration file, and defaults at the end.

# Site-wide defaults for some commonly used options.  For a comprehensive
# list of available options, their meanings and defaults, please see the
# ssh_config(5) man page.

# Host *
#   ForwardAgent no
#   ForwardX11 no
#   PasswordAuthentication yes
#   HostbasedAuthentication no
#   GSSAPIAuthentication no
#   GSSAPIDelegateCredentials no
#   BatchMode no
#   CheckHostIP yes
#   AddressFamily any
#   ConnectTimeout 0
#   StrictHostKeyChecking ask
#   IdentityFile ~/.ssh/id_rsa
#   IdentityFile ~/.ssh/id_dsa
#   IdentityFile ~/.ssh/id_ecdsa
#   IdentityFile ~/.ssh/id_ed25519
#   Port 22
#   Protocol 2
#   Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc
#   MACs hmac-md5,hmac-sha1,[email protected]
#   EscapeChar ~
#   Tunnel no
#   TunnelDevice any:any
#   PermitLocalCommand no
#   VisualHostKey no
#   ProxyCommand ssh -q -W %h:%p gateway.example.com
#   RekeyLimit 1G 1h

Host *
        SendEnv LANG LC_*
/etc/ssh/sshd_config
#       $OpenBSD: sshd_config,v 1.101 2017/03/14 07:19:07 djm Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.

#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key

# Ciphers and keying
#RekeyLimit default none

# Logging
#SyslogFacility AUTH
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin prohibit-password
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

#PubkeyAuthentication yes

# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile      .ssh/authorized_keys

#AuthorizedPrincipalsFile none

#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none

# pass locale information
AcceptEnv LANG LC_*

# no default banner path
#Banner none

# override default of no subsystems
Subsystem       sftp    /usr/libexec/sftp-server

# Example of overriding settings on a per-user basis
#Match User anoncvs

#       X11Forwarding no
#       AllowTcpForwarding no
#       PermitTTY no
#       ForceCommand cvs server
~/.ssh/config
Host *
    UseKeychain yes
    ServerAliveInterval 240
    IdentitiesOnly yes
    IdentityFile ~/.ssh/id_rsa
ls -alh ~/.ssh
[email protected] 10 man  staff   320B  2 июн 16:23 .
drwxr-xr-x+ 28 man  staff   896B  2 июн 18:37 ..
[email protected]  1 man  staff   880B  2 июн 00:53 config
[email protected]  1 man  staff   1,6K 17 мар  2017 id_rsa
[email protected]  1 man  staff   381B 26 апр  2017 id_rsa.pub
-rw-------   1 man  staff   582B  2 июн 15:24 known_hosts

ls -alh /var/empty
drwxr-xr-x   2 root  sys      64B 10 апр 05:27 .
drwxr-xr-x  26 root  wheel   832B  2 июн 03:12 ..
ls -alh /etc/ssh
drwxr-xr-x  13 root  wheel   416B  2 июн 15:26 .
drwxr-xr-x  88 root  wheel   2,8K  2 июн 04:08 ..
-rw-r--r--   1 root  wheel   540K 23 янв 05:04 moduli
-rw-r--r--   1 root  wheel   1,5K 23 янв 05:04 ssh_config
-rw-------   1 root  wheel   672B  2 июн 15:37 ssh_host_dsa_key
-rw-r--r--   1 root  wheel   622B  2 июн 15:37 ssh_host_dsa_key.pub
-rw-------   1 root  wheel   227B  2 июн 15:37 ssh_host_ecdsa_key
-rw-r--r--   1 root  wheel   194B  2 июн 15:37 ssh_host_ecdsa_key.pub
-rw-------   1 root  wheel   432B  2 июн 15:38 ssh_host_ed25519_key
-rw-r--r--   1 root  wheel   114B  2 июн 15:38 ssh_host_ed25519_key.pub
-rw-------   1 root  wheel   1,6K  2 июн 15:37 ssh_host_rsa_key
-rw-r--r--   1 root  wheel   414B  2 июн 15:37 ssh_host_rsa_key.pub
-rw-r--r--   1 root  wheel   3,1K 23 янв 05:04 sshd_config
sshd -t
➜  ~ sudo sshd -t
Password:
➜  ~ sshd -t
Could not load host key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_dsa_key
Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Could not load host key: /etc/ssh/ssh_host_ed25519_key
sshd: no hostkeys available -- exiting.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Leonchik, 2018-06-05
@AlexanderMint

In general, the matter is in the provider (hello DomRu), since only through them such nonsense happens.
And in the logs on the server when connecting the following:

Jun  4 20:44:22 IP systemd-logind[1127]: Removed session 91.
Jun  4 20:44:37 IP sshd[17681]: Connection reset by myPcIp port 50006 [preauth]
packet_write_wait: Connection to UNKNOWN port 65535: Broken pipe

Anyway, I hope this can help someone...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question