How Did I Set up My Remote SSH to My Windows PC with WSL for Python and More?

He Zhang
4 min readJan 7, 2024

I have a Windows desktop with an excellent GPU for my gaming, but I want to use it for my learning and practice machine learning with GPU.

My second computer is my Macbook laptop, which I would like to be able to SSH to my PC when I am not at home. I aim to connect to my PC and use the WSL subsystem remotely from my laptop.

The prerequisites:

  • You have installed the WSL Linux subsystem on your PC.
  1. Go into your WSL and install OpenSSH.
sudo apt-get update
sudo apt install openssh-server

2. Now, before you attempt to start the SSH server immediately, we first need to change the port number for the Linux SSH server because we are using the WSL subsystem, and we do not want to use the same default port number as the Windows SSH port number to cause any conflict.

sudo vim /etc/ssh/sshd_config
# And then uncomment and change the Port = 22 to Port = 2222 or any number you prefer.

3. You can start the SSH server! However, remember to allow port forwarding so the Windows system can port forward the connection from your Macbook to the WSL subsystem.

sudo ufw allow ssh
sudo service ssh start

You can check the status and confirm the port number is set up correctly in the log:

systemctl status ssh.service

--

--

He Zhang
He Zhang

No responses yet