-
Notifications
You must be signed in to change notification settings - Fork 859
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SSH connections hanging from WSL2 #4690
Comments
No easy guesses off the cuff, and nothing similar on the books I know of. The usual "are you running any third-party VPN or firewall software" question applies. Is it correct to say |
No active firewall / vpn
Exactly, everything works fine from cmd/ps and from WSL1 as well |
I am getting exact same issue after upgrading to windows 10 2004 and upgrading to wsl2. |
I have the same problem. Mu linux distribution is ubuntu, I tested both 18.04 and 20.04. |
I too have the same problem. I just upgraded to Windows 2004 and WSL 2 and cannot connect to hosts on the VPN network. I can however connect to hosts on AWS. When I'm using Powershell to connect to the VPN hosts it works fine, problem is only under WSL 2. Interestingly when I use docker (with the wsl2 backend enabled), to start a alpine container from within wsl2 and I try to ssh into one of the hosts from there it works just fine. |
I have the same issue. |
I started having this issue since two days ago. I'm not exactly sure what changed, I didn't make any new install/upgrade. Running W10 - 2004, Ubuntu 18.04 @ WSL 2 |
Same problem:
|
This (in PowerShell) appears to work around this issue for me: New-NetFirewallRule -DisplayName "WSL" -Direction Outbound -InterfaceAlias "vEthernet (WSL)" -Action Allow Inspired by this comment: #4585 (comment). |
Same problem here |
I have also the same problem with 2004, connecting via SSH over VPN works but then simple commands like top freezes everything. |
I'm having this issue too. SSH will hang randomly when connected to VPN. Sometimes from cat or grep or sometimes immediately upon connecting to a host. Ubuntu 18.04 in WSL2 on Windows 10 2004. |
No VPN or firewall & I'm on WSL2
But if I revert to wsl1
It works ! 👍
|
It didn't work for me. I had to restart the PC once or twice to fix it. |
I am also having the same issue. The Windows Firewall rule posted by @lbergnehr did not work for me. I can navigate a few directories, but commands like |
Changing MTU fixed the problem for me: |
I had this problem when using Docker for Windows with WSL2.. After shutting down docker the problem didn't occur anymore. |
I also have this problem in WSL2 - nothing of these worked for me: OS: |
I have the same issue with WSL 2 Once logged into ssh server the session hangs up shortly. WSL 1 works like a charm. |
This may be unrelated, but I can't SSH into my EC2 instance in AWS. I get a message that the host closed the connection. I can SSH from PowerShell and Putty just fine with my keys. I'm using Ubuntu 20.04 LTS with WSL2 |
Same problem here. Connecting through ssh to a linux server hangs when I try to use some Linux commands. I am using Ubuntu 20.04.1 LTS |
Having the same issue.... but I cannot connect at all, it just hangs, eventually times out and then it works just fine... Ubuntu 18.04 LTS |
I will post for the first time.
I haven't figured out the cause, but I found two workarounds.
|
I also have this issue in WSL2. |
I am getting this too using I can confirm this works for me:
From that comment: ...But that needs to be run every time the VM reboots which is not ideal. I'm not certain what would be needed to set the MTU to that value on the VM permanently - I don't have anything in |
Thanks to nadavpa and rob-baker-ar for their comments.
This is an event where ssh hangs, but since the effectiveness of the workaround is different, |
Same issue. Windows 10 build 20H2. |
This seems to help a little bit. I had problems when using SSH via WSL2, while running Wireguard Client ( on Windows ). SSH would freeze constantly ( top or htop would freeze the connection ). SSH works just fine when using it from Powershell, while VPN is on. |
Thanks for the command. In my case it seems it works fine until 1314 and stops working from 1315. I had this issue for a while, but until today it was temporary - running |
Great support Microsoft! |
I have "solved" this issue: Removed WSL + all Hyper-V stuff and moved over to VirtualBox with a dedicated Linux VM. |
I have 'solved' this problem by simply using the power shell with ssh and scp ... |
I've been playing with this issue over the past couple weeks. Here is what I've adjusted (and automated for new VMs), done to cope, and what else I've observed: Manifestation conditionsFor me, I have not experienced trying to connect and not being able to do anything at all with SSH. I suspect that issue and how it is manifesting for me are different underlying issues. As pointed out by @andreasmarkussen , this thread is probably capturing multiple different underlying issues from different people. It also captures them over time, as WSL and the OSes involved have shifted. For instance, the MTU aspect seems to have zero implications for me, and I can't help but think that was applicable for the earlier manifestations only and Microsoft has since fixed that aspect - or maybe I'm just lucky.
Coping with disconnectionsI've always been a fan of using screen for remote connections so that I could detatch and disconnect, and later reconnect and re-attach to the session, kept running int he background until I got back. Generally, I'd not bothered to use it when first setting up VMs, but I began to become more aggressive in its use with this issue, using If you've not used screen or similar terminal multiplexera, I highly recommend using this for remote connections in general. SSH ConfigurationBelow is an automation function (written with bash in mind) being used with cloud-init Note, in terms of sequence it is important to take care when you run this while launching a new VM. There are two primary considerations: 1) not getting locked out of your system, 2) making a mess of things during system updates.
|
I had similar issues with VPN traffic, have you tried enabling |
Thanks for the suggesion, did nothing here. |
So I had also problems with my ssh connections on my desktop PC for a long time now. For me, the MTU did not help at all, but now it seems that the problem for me was being connected through Wi-Fi and Ethernet at the same time. Since I switched off my Wi-Fi antenna, the connection freezes and loop breakdowns seem to have stopped (for at least about half an hour now...). |
Sharing my anecdata: in a WSL2 client, when I crank up the SSH client verbosity, this is what I get:
at which point it hangs until eventually I get Server logs (seen via
which suggests to me that packets in the key exchange are getting dropped somewhere in the response path in a non-deterministic fashion. The fact that some folks can get around this by twiddling random network settings about packet size I think corroborates this; if the non-determinism was intrinsically the result of, say, some kind of byte truncation for large packets, then I could see that happening. |
Debian 11 (bullseye) in WSL2 shows the ssh hanging as well. |
Time to time this occurs to me too. I had changed MTU to 1350 and that had fixed the issue. Now when it occurs I just restart my laptop unfortunately. |
Time for yet another bump:
$ uname -a $ cat /etc/os-release SSH fails after random periods. Even with continual traffic, keepalives etc. |
Same issue: SSH does not connect at all (while putty or ssh.exe in terminal does work). |
WSL2 on Debian 12 (bookworm) i don't see any problems, unlike Ubuntu 22.04 |
In my experience, WSL2 is 💩. |
MPU of the eth0 adapter is the causeIn case anyone has in the same issue. I do not find the logic of the issue. I tried all options and none worked. My setup is:
As one solution I read that you have to match the MTU of your VPN adapter and WSL eht0 adpater. That did not work for me. Honestly I just started testing random MTU number until it worked with 700. You can try several values and maybe it helps you |
Hi. Can you please collect networking logs by following the instructions below? |
This worked for me when hanging on git push in WSL2. Attached the following logs. First with MTU at 1500 then with MTU at 1400 |
I did the following, which worked for me (Windows 10 & WSL2):
|
it's still not fix??? |
Sort of related problem "here". It all looks to be related to Windows Defender doing weird things. Disabling the Windows Defender is not an option, since it is controlled by my Security Department. I try to "scp" a file about ~20Mbytes in size from machine A (WSL guest) to machine B (remote cloud machine). scp starts normally, with a copy speed of about 500Kbytes/seconds. Then performance starts to degrade until the copy stalls. I can manage to skip the Windows Defender lock ("sort of") with the next trick:
In summary:
Edit: In my "Works for me" scenario, setting MTU to the biggest possible value (65530) makes things work faster, specially for localhost connections. |
Current Version 10.0.19025.1
I have this weird issue where I can no longer use SSH connections to remote servers from WSL2. I remember that it was working ok in early builds but I am not sure at which point it started to fail.
Any idea on how to resolve this would be appreciated.
What happens
When connected to a remote server, SSH connection hangs after a very short time. I am sometimes able to type a few letters but then it hangs and have to close WSL. It does this with every SSH connections to every server.
For instance, on the following screenshot, you can see that I was able to type a few numbers but the connection froze at the last "1".
Probably related, SSH git cloning is not working either. It starts receiving objects but stops shortly after. I have to CTRL-C to stop. Here's an example hanging at 46%.
> GIT_SSH_COMMAND="ssh -vvv" git clone --verbose git@github.com:microsoft/dotnet.git
...

In WSL1, everything works smoothly and have no issues. It's only in WSL2 that this happens.
Note that git cloning through HTTPS works fine as well.
Just let me know if there is additional trace I can run to help since I know this is probably going to be hard to repro.
The text was updated successfully, but these errors were encountered: