核心内容摘要
BrazzersXXXXJuliaann
下载https://github.com/PowerShell/Win32-OpenSSH/releases→ 选择OpenSSH-Win
msiStart-Service sshd Set-Service -Name sshd -StartupType Automatic#
安装 OpenSSH Server如果没装 sudo apt update sudo apt install -y openssh-server【解决】Ubuntu使用root账户ssh连接失败 - 知乎cat /etc/ssh/sshd_config EOF Port 2222 PermitRootLogin yes PasswordAuthentication yes PubkeyAuthentication no UsePAM no UseLogin yes ListenAddress
0.
0.
0 EOF要在wsl里面设置密码不能用wsl -u root passwdpasswd打开sshdssh-keygen -A# 杀死旧进程 sudo pkill -f sshd # 启动新服务 sudo /usr/sbin/sshd测试连接ssh -p 2222 rootlocalhost步骤 1添加端口转发规则以管理员身份运行 PowerShell# 删除旧规则如果存在 netsh interface portproxy delete v4tov4 listenport2222 listenaddress
0.
0.
0 # 添加新规则将
192.
168.
3:2222 转发到 WSL2 的
127.
0.
1:2222 netsh interface portproxy add v4tov4 listenport2222 listenaddress
0.
0.
0 connectport2222 connectaddress
127.
0.
1步骤 2允许防火墙通过 2222 端口# 允许入站连接 New-NetFirewallRule -DisplayName WSL2 SSH -Direction Inbound -Protocol TCP -LocalPort 2222 -Action Allow现在可以从其他设备如手机、另一台电脑连接ssh -p 2222 root
192.
168.