WSL: SSH to remote causes disconnect with client_loop: send disconnect: Broken pipe

Version

Microsoft Windows [Version 10.0.22000.434]

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.10.60.1

Distro Version

Ubuntu 20.04

Other Software

No response

Repro Steps

ssh to any remote machine from Ubuntu 20.04 under WSL. ssh from Powershell works without issues.

Expected Behavior

ssh connection should persist and stay connected

Actual Behavior

Consistent disconnects after a few seconds:

$ ssh upfront4                                                                                                                  bash  19:28:08 
Linux upfront4 4.19.0-18-amd64 #1 SMP Debian 4.19.208-1 (2021-09-29) x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
You have new mail.
Last login: Mon Jan 24 13:19:23 2022 from 102.39.132.97
roche@upfront4:~$ sudo -i
[sudo] password for roche: client_loop: send disconnect: Broken pipe

Diagnostic Logs

networking.bat.log wsl.etl.zip

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 21

Most upvoted comments

what helped a little in my case (client_loop: send disconnect: Broken pipe) to keep a connection longer is to set the ServerAliveCountMax parameter to a higher value, e.g. 100 in .ssh/config:

Host *
    ForwardAgent yes
    AddressFamily inet
    TCPKeepAlive yes
    ServerAliveInterval 60
    ServerAliveCountMax 100
    IPQoS 0

The following did not help, but currently in place: in WSL:

# echo 1 | sudo tee /proc/sys/net/ipv4/tcp_mtu_probing # did not help, commented out
sudo ifconfig eth0 mtu 1350

in Windows:

netsh interface ipv4 set subinterface "vEthernet (WSL)" mtu=1350 store=persistent

I have not changed the interface metric settings, as I use an Ethernet adapter on my working station.

This is definitely a WSL2 issue, since the same .ssh/config is used for WSL ssh and for the Windows OpenSSH client.

I don’t understand, why the ticket has been closed. Guys at MS, you cannot imaging how much time I waste on working around this issue.

I already had the following in ~/.ssh/config before logging this issue:

Host *
ServerAliveInterval 60

I just added TCPKeepAlive no and I still hit the same error. If it is not a WSL issue, why don’t I experience the same issue when using ssh under Windows?

@equation-group changing MTU or DNS settings does not work for me. I saw this comment explaining how to change “Auto metric” on the TCP/IP settings for the adapter to “1” and that seems to work! I will log ping stats for a few days to confirm.

Hi there. I’m having the same issues.

My log with verbose:

vpablos@WKS0001108274:~$ ssh -v -o TCPKeepAlive=yes -o ServerAliveCountMax=20 -o ServerAliveInterval=15 localhost
OpenSSH_8.2p1 Ubuntu-4ubuntu0.4, OpenSSL 1.1.1f  31 Mar 2020
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to localhost [127.0.0.1] port 22.
debug1: Connection established.
debug1: identity file /home/vpablos/.ssh/id_rsa type 0
debug1: identity file /home/vpablos/.ssh/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.2p1 Ubuntu-4ubuntu0.4
debug1: match: OpenSSH_8.2p1 Ubuntu-4ubuntu0.4 pat OpenSSH* compat 0x04000000
debug1: Authenticating to localhost:22 as 'vpablos'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:41liDTj8s2Y10brK8MN63e8eoMVs3q0GrKc/AVk+RDE
debug1: Host 'localhost' is known and matches the ECDSA host key.
debug1: Found key in /home/vpablos/.ssh/known_hosts:6
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /home/vpablos/.ssh/id_rsa RSA SHA256:pvyMfM8ata4DoXBG9jnPkTUHqrQIFoVBxGaS9L0sf0U agent
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,sk-ssh-ed25519@openssh.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ecdsa-sha2-nistp256@openssh.com>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering public key: /home/vpablos/.ssh/id_rsa RSA SHA256:pvyMfM8ata4DoXBG9jnPkTUHqrQIFoVBxGaS9L0sf0U agent
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: keyboard-interactive
Password:
debug1: Authentication succeeded (keyboard-interactive).
Authenticated to localhost ([127.0.0.1]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: exec
client_loop: send disconnect: Broken pipe
vpablos@WKS0001108274:~$