WSL: sshd ssh_exchange_identification error

Hi, I have a strange issue. My sshd started to fail recently. When sshing to the server, all clients fail with the error: ssh_exchange_identification: Connection closed by remote host. I’ve checked everything on the internets and stackoverflow, but I don’t have a hosts.allow file, nor anything special in ssh_config, set up MaxStartups both the new and the old way - but nothing seems to make it work again. I did an lxrun /uninstall /full + lxrun /install , to clear everything - but same results.

I’m now on 10.0.16176; I’m sure my stack was working till 2017-04-10 (you may figure out the last working version, as I’m on the fast dev channel). I’ve checked on another machine, 10.0.15063, the same config works.

I’ve tried to debug, I see the following:

`balint@xxx:~$ ssh balint@192.168.2.105 -p22 -vT

OpenSSH_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g 1 Mar 2016

debug1: Reading configuration data /etc/ssh/ssh_config

debug1: /etc/ssh/ssh_config line 19: Applying options for *

debug1: Executing proxy command: exec nc 192.168.2.105 22 debug1: permanently_drop_suid: 1000 debug1: key_load_public: No such file or directory debug1: identity file /home/balint/.ssh/identity type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/balint/.ssh/identity-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/balint/.ssh/id_rsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/balint/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/balint/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/balint/.ssh/id_dsa-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.1 ssh_exchange_identification: Connection closed by remote host`

and running sshd in debug mode:

`balint@xxxx:~$ sudo /usr/sbin/sshd -p22 -dddd

debug2: load_server_config: filename /etc/ssh/sshd_config debug2: load_server_config: done config len = 792 debug2: parse_server_config: config /etc/ssh/sshd_config len 792 debug3: /etc/ssh/sshd_config:5 setting Port 22 debug3: /etc/ssh/sshd_config:8 setting ListenAddress 192.168.2.105 debug3: /etc/ssh/sshd_config:10 setting Protocol 2 debug3: /etc/ssh/sshd_config:12 setting HostKey /etc/ssh/ssh_host_rsa_key debug3: /etc/ssh/sshd_config:13 setting HostKey /etc/ssh/ssh_host_dsa_key debug3: /etc/ssh/sshd_config:14 setting HostKey /etc/ssh/ssh_host_ecdsa_key debug3: /etc/ssh/sshd_config:15 setting HostKey /etc/ssh/ssh_host_ed25519_key debug3: /etc/ssh/sshd_config:17 setting UsePrivilegeSeparation yes debug3: /etc/ssh/sshd_config:20 setting KeyRegenerationInterval 3600 debug3: /etc/ssh/sshd_config:21 setting ServerKeyBits 2048 debug3: /etc/ssh/sshd_config:24 setting SyslogFacility AUTH debug3: /etc/ssh/sshd_config:25 setting LogLevel VERBOSE debug3: /etc/ssh/sshd_config:28 setting LoginGraceTime 120 debug3: /etc/ssh/sshd_config:29 setting PermitRootLogin prohibit-password debug3: /etc/ssh/sshd_config:30 setting StrictModes yes debug3: /etc/ssh/sshd_config:32 setting RSAAuthentication yes debug3: /etc/ssh/sshd_config:33 setting PubkeyAuthentication yes debug3: /etc/ssh/sshd_config:37 setting IgnoreRhosts yes debug3: /etc/ssh/sshd_config:39 setting RhostsRSAAuthentication no debug3: /etc/ssh/sshd_config:41 setting HostbasedAuthentication no debug3: /etc/ssh/sshd_config:46 setting PermitEmptyPasswords no debug3: /etc/ssh/sshd_config:50 setting ChallengeResponseAuthentication no debug3: /etc/ssh/sshd_config:53 setting PasswordAuthentication no debug3: /etc/ssh/sshd_config:65 setting X11Forwarding yes debug3: /etc/ssh/sshd_config:66 setting X11DisplayOffset 10 debug3: /etc/ssh/sshd_config:67 setting PrintMotd no debug3: /etc/ssh/sshd_config:68 setting PrintLastLog yes debug3: /etc/ssh/sshd_config:69 setting TCPKeepAlive yes debug3: /etc/ssh/sshd_config:76 setting AcceptEnv LANG LC_* debug3: /etc/ssh/sshd_config:78 setting Subsystem sftp /usr/lib/openssh/sftp-server debug3: /etc/ssh/sshd_config:89 setting UsePAM yes debug1: sshd version OpenSSH_7.2, OpenSSL 1.0.2g 1 Mar 2016 debug1: private host key #0: ssh-rsa SHA256:P2fM… debug1: private host key #1: ssh-dss SHA256:+tZ0O… debug1: private host key #2: ecdsa-sha2-nistp256 SHA256:zkhO5QO… debug1: private host key #3: ssh-ed25519 SHA256:19aPKyu… debug1: rexec_argv[0]=‘/usr/sbin/sshd’ debug1: rexec_argv[1]=‘-p22’ debug1: rexec_argv[2]=‘-dddd’ debug3: oom_adjust_setup debug1: Set /proc/self/oom_score_adj from 0 to -1000 debug2: fd 3 setting O_NONBLOCK debug1: Bind to port 22 on 192.168.2.105. Server listening on 192.168.2.105 port 22. debug3: fd 4 is not O_NONBLOCK debug1: Server will not fork when running in debugging mode. debug3: send_rexec_state: entering fd = 7 config len 792 debug3: ssh_msg_send: type 0 debug3: send_rexec_state: done debug1: debug1: inetd sockets after dupping: 3, 3 Connection from with IP options: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00`

and here it exists back to bash.

In some cases, sources say it might be a DDOS attack (too many connections), but I closed the 22 port on the firewall, and it does it with local traffic only too.

Any thoughts?

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 21 (10 by maintainers)

Most upvoted comments

The PR (pull-request) is out for review. We will try to get it fast tracked to the Insider build.

@sunilmut I can confirm, it has to be a bug with IP_OPTIONS. I’ve commented out the #ifdef part for IP_OPTIONS in sshd.c (see: https://anongit.mindrot.org/openssh.git/tree/sshd.c#n1311 ) rebuilt it, and sshd started working as expected.

I’m just wondering how come no others are complaining about a broken ssh server?

Nah, we’re seeing it. You happened to post within hours of 16176 coming out, and there are (against best evidence) a few of us left who check before reporting dupes. The problem is unambiguously a result of IP_OPTIONS.

@kbalint - Thanks much and good catch! 16176 is a fairly new, I would expect more reports of this as we go.

I am fairly sure this is the check that is blowing up:

option_size != 0

On native Ubuntu, the size returned is 0. WSL returns the same size that was supplied, which is commonly the case.

Working on a fix now.

Seems okay on 16193. I don’t know what’s up with the release notes page. Probably everyone was occupied with Build 2017 this week.

@sunilmut thanks for your help, my backups can flow again! The trace is here: https://pastebin.ubuntu.com/24429187/ Reproducible steps? Well, wake up to a Black Screen of ‘Hi!’, and your linux life is in ruins. 😉