Link to home
Start Free TrialLog in
Avatar of Alexandre Takacs
Alexandre TakacsFlag for Switzerland

asked on

Confused about WSL networking


I am giving a try to Windows Subsystem for Linux on a Server 2019.

Overall thing have been relatively smooth so far and I am successfully running Ubuntu 18 - nice...

I am not sure to fully understand how networking is supposed to work. My understanding is that my Windows server is also an Ubuntu machine ?! I'd like to SSH from my LAN to my Ubuntu "instance" - I have disabled the Windows Firewall, made sure open SSH is active but I still can't seem to reach into the Ubuntu - I get

ssh admin@
ssh: connect to host port 22: Connection refused

Open in new window

What am I missing here ?
Avatar of arnold
Flag of United States of America image

Run ifconfig in the Ubuntu instance, is sshd running?
Ps -ef |grep sshd
Avatar of Alexandre Takacs


Is see the expected local IP ( and the SSH deamon

admin@hvneuchatel:~$ ps
  PID TTY          TIME CMD
    4 tty1     00:00:00 bash
   16 tty1     00:00:00 ps
admin@hvneuchatel:~$ ps -ef |grep sshd
synergi+    18     4  0 13:01 tty1     00:00:00 grep --color=auto sshd
admin@hvneuchatel:~$ ifconfig

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet  netmask  broadcast
        inet6 fe80::ad7f:37e9:1dc0:36b7  prefixlen 64  scopeid 0xfd<compat,link,site,host>
        ether 3c:ec:ef:20:20:cd  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 1500
        inet  netmask
        inet6 ::1  prefixlen 128  scopeid 0xfe<compat,link,site,host>
        loop  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)

Open in new window

As arnold mentioned, you must have sshd running.

This brings up a massive problem with WSL.

WSL != Linux

Take Ubuntu for example, with Ubuntu to get sshd running is simple.

apt-get install openssh-server

Open in new window

This command installs sshd, arranges for sshd to start immediately, arranges for sshd to restart each reboot, installs Fail2Ban to block brute force password attacks.

With WSL, you will have to either find packages for openssh-server + fail2ban ported to WSL, or more likely you will have to build them both, then arrange your own house keeping (starting processes now + at each reboot).

So with WSL, it appears, whenever you'd like to get some code running... you'll have to repeat these steps...

If you're just learning, this seems like a great opportunity for learning WSL.

If you're working on money projects keeping your lights on (where time is money), then you'll install Ubuntu on a physical machine, then use VirtualBox to run Windows to handle any Windows code you might have to run.

I suggest Ubuntu, as the APT package manager, to me, is great because it's dependency handling is stellar.
This command installs sshd, arranges for sshd to start immediately, arranges for sshd to restart each reboot, installs Fail2Ban to block brute force password attacks.

Just to be clear I have installed Ubuntu 18 under WSL. Then I did indeed use apt: sshd installed and started (as per process list above). It would "just" seem it is not listening on the local ETH0...
Look at possibly another option.
The server can have openssh client and server installed as a Windows-feature.
See whether the option exist to launch, wls.

VM of Ubuntu under hyper-v, virtualbox ..

Issue deals whether wsl is running or launched as needed...
Avatar of Alexandre Takacs
Alexandre Takacs
Flag of Switzerland image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
A restart as my question (to check whether sshd is running) suggested will first try to stop sshd if running, and then start it.

By default sshd service is not started within wsl.
Thanks for your suggestion & explanations. I guess this is a bit of an "edge" case but I'm really curious to fully understand how this really works.
it runs an app within the confines of windows that has direct access to the underlying hardware.
close the Ubuntu app, and what was running is termed.
depending on what you are trying to do.

but I guess I can auto start the Ubuntu App ?

And when it is running I get some hybrid machine the runs both Windows and Ubuntu (not in separated VM but within the same execution space). Not sure if / how this can be actually useful but it is an interesting experiment for a confined Sunday...
The useful depends on what you do, some use Python, and other scripting tools than in this wsl they can use to access the data onthe computer without needing to transfer the data first into a Linux VM to do what they need and put the results back....

Starting the app, might not auto start the sshd service. Though have not locked into it.