远程登录Windows的WSL子系统
WSL
Issues found on WSL
项目地址:https://gitcode.com/gh_mirrors/ws/WSL

·
很多文章要么只有安装 wsl 和 ssh,要么只有设置端口转发,完全不能一篇文章解决标题中的问题
由于最近不在办公室,需要远程登录办公室的电脑,这样可以节省很多时间去配置各种命令
回归正题,首先你需要确定你可以远程访问你的 windows 电脑(不能远程访问的可以退出了),而 wsl 可以看作和 Windows 在同一“路由器”下的电脑,远程登录需要开启“路由器”的端口转发功能,将 wsl 的 ssh 端口转发到远程可以访问的“路由器”网段下
我这里的 wsl 是 ubuntu 系统,如果你是其他系统,下面提到的 wsl 部分命令需要替换
操作步骤
- 在 wsl 中使用 ifconfig 命令查看 IP,假设为 10.10.10.2
- 使用管理员权限打开 cmd,我这里是将 wsl 的 ssh 端口转发到 windows 的 22222 端口
netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=22222 connectaddress=10.10.10.2 connectport=22
- 放行 windows 的 22222 端口,WSL2 是这条放行规则的别名
netsh advfirewall firewall add rule name=WSL2 dir=in action=allow protocol=TCP localport=22222
- 在 wsl 中开启其他地址的访问权限
sudo vim /etc/hosts.allow # 在最下方添加 ALL:ALL
sudo service ssh restart
FAQs
Q : 远程连接时出现 ssh_exchange_identification:read:Connection reset by peer
A : 执行上面的第 4 步,开启访问权限




Issues found on WSL
最近提交(Master分支:8 个月前 )
9f6c33f4
* Update install-latest-wsl.ps1
https://github.com/microsoft/WSL/issues/12282#issuecomment-2480894130 The install-latest-wsl.ps1 script cannot parse the operating "System Type" '$systeminfo = & systeminfo | findstr /C:"System Type"' due to language problems. In the Chinese interface environment, "System Type" is the Chinese "系统类型".
* Updated regular syntax 2 天前
d3f37e41
13 天前
更多推荐
所有评论(0)