sshing to localhost WSL2 is unstable at best. misery and despair


  1. Posts : 11
    Windows 10 Pro
       #1

    sshing to localhost WSL2 is unstable at best. misery and despair


    I have a wsl issue that's been driving me mad for weeks: when booting the pc, there's a big chance that ssh connections to wsl won't be operational until one or more reboots. I get a Connection refused error.
    I went through lots and lots of similar github issues, but none of them really went anywhere.
    I think my localhost forwarding is fine, because I can access a wsl http server (python3 -m http.server 8080) from the browser on Windows (http://localhost:8080/). VSCode's remote development works fine too, it uses a custom server.
    I have Bitdefender's firewall enabled, and while currently there's a bug that breaks ICMP ping to localhost when the firewall is enabled, everything works the same with it either being on or off. Network level interferences are usually logged, no entries are created, so maybe it can be excluded.

    My ssh has been configured by this script, I see no obscure things there. I use ssh through CLion to do cross platform C development and it's amazing, when it works.
    sshd_config:
    Code:
    # configured by CLion
    ListenAddress 127.0.0.1 #i've tried 0.0.0.0 too, just to try
    Port 2222
    UsePrivilegeSeparation no
    PasswordAuthentication yes

    I'm an IT student, but I'm not an experienced Linux user. My vm is using Ubuntu 20.04, regularly updated.

    Some people have mentioned that localhost is resolved to ::1 on windows, and Ubuntu is expecting a IPv4 address instead. I'm not too sure about that.. This setup occasionally does work.

    I'm pretty much lost and I don't know what to think of anymore.
    Windows 10 Pro 20H2 19042.630
      My Computer


  2. Posts : 11,247
    Windows / Linux : Arch Linux
       #2

    Lucide said:
    I have a wsl issue that's been driving me mad for weeks: when booting the pc, there's a big chance that ssh connections to wsl won't be operational until one or more reboots. I get a Connection refused error.
    I went through lots and lots of similar github issues, but none of them really went anywhere.
    I think my localhost forwarding is fine, because I can access a wsl http server (python3 -m http.server 8080) from the browser on Windows (http://localhost:8080/). VSCode's remote development works fine too, it uses a custom server.
    I have Bitdefender's firewall enabled, and while currently there's a bug that breaks ICMP ping to localhost when the firewall is enabled, everything works the same with it either being on or off. Network level interferences are usually logged, no entries are created, so maybe it can be excluded.

    My ssh has been configured by this script, I see no obscure things there. I use ssh through CLion to do cross platform C development and it's amazing, when it works.
    sshd_config:
    Code:
    # configured by CLion
    ListenAddress 127.0.0.1 #i've tried 0.0.0.0 too, just to try
    Port 2222
    UsePrivilegeSeparation no
    PasswordAuthentication yes

    I'm an IT student, but I'm not an experienced Linux user. My vm is using Ubuntu 20.04, regularly updated.

    Some people have mentioned that localhost is resolved to ::1 on windows, and Ubuntu is expecting a IPv4 address instead. I'm not too sure about that.. This setup occasionally does work.

    I'm pretty much lost and I don't know what to think of anymore.
    Windows 10 Pro 20H2 19042.630
    Hi there

    On Windows - install the optional application - openssh server and ensure its active and started at boot (via services)

    On any Linux system (the WSL included) ensure that openssh is installed and service SSHD is up and running -- enable it also as root by typing (as root - su or sudo) systemctl enable sshd and check its active (systemctl status sshd).

    Cheers
    jimbo
      My Computer


  3. Posts : 11
    Windows 10 Pro
    Thread Starter
       #3

    On the vm, systemctl doesn't work:
    Code:
    > sudo systemctl enable sshd
    Failed to enable unit, refusing to operate on linked unit file sshd.service
    > sudo systemctl status sshd
    System has not been booted with systemd as init system (PID 1). Can't operate.
    Failed to connect to bus: Host is down
    But service does:
    Code:
    > sudo service ssh status
     * sshd is running
    I've often restarted the service both with sudo service ssh restart and sudo service ssh --full-restart, no luck.
    I don't use a ssh server on Windows, but I've tried other clients besides CLion's built-in, the powershell one, the git bash one and PuTTY
      My Computer


  4. Posts : 11,247
    Windows / Linux : Arch Linux
       #4

    Hi there
    another problem is that the networking hasn't been enabled between the VM and host -- try ifconfig on the Linux system --if its on a different subnet it won't work -- you usually need some sort of "Bridged" networking .

    Before messing about with WSL I'd practice with a proper Linux VM first -- use VMWare player (free) and use bridged networking.

    Cheers
    jimbo
      My Computer


  5. Posts : 11
    Windows 10 Pro
    Thread Starter
       #5

    The point of using WSL is that, despite being a hyper-V vm, it comes already configured to behave as similarly as possible as a wsl v1. There's no need to configure the virtual network further.
    I think I remember it's not a "fully bridged" vm, that means that communication inside the machine is possible, but it can't be reached from outside like wsl1 could. That's reasonable, microsoft is still balancing between functionality missed by wsl1 users and what a classical vm requires.
    To highlight that, I actually have the hyper-v "windows feature" disabled, despite the level 1 hypervisor being engaged.
    I don't have the hyper-v vm management tools installed, as I don't need them.

    I would like to mention this point again:

    Lucide said:
    I think my localhost forwarding is fine, because I can access a wsl http server (python3 -m http.server 8080) from the browser on Windows (http://localhost:8080/). VSCode's remote development works fine too, it uses a custom server.
    Other services that are not ssh always work.
      My Computer


  6. Posts : 11,247
    Windows / Linux : Arch Linux
       #6

    Lucide said:
    The point of using WSL is that, despite being a hyper-V vm, it comes already configured to behave as similarly as possible as a wsl v1. There's no need to configure the virtual network further.
    I think I remember it's not a "fully bridged" vm, that means that communication inside the machine is possible, but it can't be reached from outside like wsl1 could. That's reasonable, microsoft is still balancing between functionality missed by wsl1 users and what a classical vm requires.
    To highlight that, I actually have the hyper-v "windows feature" disabled, despite the level 1 hypervisor being engaged.
    I don't have the hyper-v vm management tools installed, as I don't need them.

    I would like to mention this point again:



    Other services that are not ssh always work.
    Hi there
    the trouble with Ms's "canned WSL distros" is that they are getting way behind current Linux kernels -- especially as you've found out -- the whole way of the "systemd" booting thing. -- i.e when systemctl command doesn't work or isn't operative. Network config protocols also have been a lot updated as well.

    WSL when it came out was IMO brilliant even though it had limited capability (WSL 1). WSL 2 seems to be a bit of a disappointment currently -- and given modern hardware and the vast improvement in Virtualisation platforms - together with the performance of Virtual Machines themselves it seems to me that WSL has"missed the boat" and doesn't bring anything extra to the table any more.

    For scripting there's always things like python which runs on Windows if one wants to try things like A.I development etc on a Windows platform. Bash of course is a far better "scripting command processor" than the basic Windows one but as to how much users need the sophistication of that to me is a moot point anyway.

    So I think (although others might have totally different views) that WSL is going nowhere and you'd be far better off with classical VMs".

    I was very positive at the start of WSL but have given up entirely on it now.

    (Another topic - but the same with Windows attempt at "Sandboxing" -- not being able to preserve software updates and configurations after a re-boot of the sandboxed system rather makes the whole thing really worse than useless - lots of software needs re-booting after installation or configuration changes).

    Cheers
    jimbo
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 15:15.
Find Us




Windows 10 Forums