search terms:
- Edit the SSH configuration file to enhance security (e.g., change the default port, disable password authentication for key-based authentication):
- Modify or add lines as needed (e.g.,
Port 2222,PasswordAuthentication no,PubkeyAuthentication yes). - Save and exit the file.
- Restart the SSH service for changes to take effect:
- Open PowerShell as Administrator on your Windows host.
- Get the IP address of your WSL instance and set up port forwarding. Replace
2222with your chosen SSH port if you changed it insshd_config:
- Open Windows Defender Firewall with Advanced Security.
- Create a new Inbound Rule:
- Select "Port" and click Next.
- Choose "TCP" and enter the port number you are using for SSH (e.g., 2222).
- Allow the connection and apply the rule to all profiles.
- Name the rule (e.g., "WSL SSH") and finish the wizard.
- Generate Key on Client (e.g., your Windows machine or another remote machine):