- Published on
SSH Straight Into WSL2 Like a Real Linux Server (No Windows Quirks)
- Authors
- Name
- Hachiro
Remember when remote development meant juggling multiple machines, SSH configs, and maybe a few tears when things didn't connect? These days, things are simpler—if you know how to make the right pieces work together.
One of the neatest tricks is making Windows Subsystem for Linux 2 (WSL2) act like any other Linux remote. No jumping through hoops with the official Windows OpenSSH server, no dealing with weird path differences. Instead, you can forward port 22 on Windows straight into WSL2 and SSH directly into your Linux environment. Combine this with something like Tailscale or your own self-hosted VPN, and suddenly, you have a private, secure, developer-friendly setup that feels just like working with a real remote server.
Let's break it down: why, when, and how.

Why would you even do this?
If you're like me and use WSL2 as your main development environment, you know it already behaves like a Linux machine inside Windows. But when you want remote access—maybe to connect from another PC, your laptop, or even a mobile terminal—Windows gets in the way.
Sure, you could install and enable the Windows OpenSSH server. But the paths, tools, and syntax feel off if you're used to proper Linux. Suddenly, your .ssh
keys are buried under C:\Users
, permissions behave differently, and it doesn't feel quite right.
By forwarding Windows' port 22 directly into WSL2's port 22, you skip the middleman. What you get is:
- A native Linux SSH experience: No Windows quirks in your way.
- Consistency: Same config, same tools, same paths as any remote Linux host.
- Security and flexibility: Add Tailscale or a WireGuard tunnel and you have a private, encrypted route to your dev box from anywhere.
- No more third-party tools: Eliminate the need for AnyDesk, TeamViewer, or other proprietary remote access software that can be slow, insecure, or require constant updates.
When this makes sense
This isn't for everyone. If you only occasionally use WSL2 or prefer Windows-native tooling, the official OpenSSH server might be enough. But if you:
- Spend most of your time in Linux tooling inside WSL2
- Use multiple machines for development
- Want a "real" Linux remote experience
- Plan to integrate this into a private VPN network
- Want to ditch third-party remote access tools like AnyDesk or TeamViewer
…then this setup is worth the small effort.
How to make it work
The idea is simple:
- Run SSH inside WSL2
- Forward Windows port 22 to WSL2
- Secure it with VPN if you want remote access
Here's a minimal setup:
1. Install and enable SSH in WSL2
Inside your WSL2 distro:
sudo apt update
sudo apt install openssh-server
# Start SSH service:
# For Arch Linux, RHEL, CentOS, Fedora:
sudo systemctl start sshd
# For Debian/Ubuntu:
# sudo systemctl start ssh
You might also want to enable SSH on boot:
# For Arch Linux, RHEL, CentOS, Fedora:
sudo systemctl enable sshd
# For Debian/Ubuntu:
# sudo systemctl enable ssh
Make sure you can SSH in locally:
ssh localhost
2. Forward Windows port 22 to WSL2
On Windows, open PowerShell as Administrator and run:
netsh interface portproxy add v4tov4 listenport=22 listenaddress=0.0.0.0 connectport=22 connectaddress=<WSL2_IP>
Find your WSL2 IP with:
ip addr | grep eth0
This command tells Windows to forward all SSH traffic hitting port 22 straight into your WSL2 instance.
3. Make it accessible remotely (optional)
If you only plan to connect from the same PC or LAN, you're done. But if you want remote access, don't expose port 22 directly to the internet.
Instead, use something like Tailscale or a self-hosted WireGuard VPN. Both create secure tunnels so you can SSH into your WSL2 box from anywhere—without messing with firewalls or public IPs.
ssh user@<tailscale-ip>
Now you have private, encrypted access to your dev environment wherever you are.
Putting it all together
With this setup, your WSL2 machine behaves like any other Linux server. You connect with a single ssh
command, use your standard ~/.ssh/config
, and even automate deployments or development scripts exactly like on a cloud VM.
Add Tailscale or WireGuard on top, and you've basically built a secure remote dev box that lives on your own hardware. No third-party remote desktop tools, no clunky Windows SSH server, just a clean, open-source stack.