前提
基于前面wsl转发到了2222端口的基础
0. WSL:确保 sshd 在 2222 正常
# 在 WSL
sudo sed -i 's/^#\?Port .*/Port 2222/' /etc/ssh/sshd_config
sudo service ssh restart
ss -lntp | grep :2222
# 期望看到:LISTEN ... 127.0.0.1:2222 ... sshd
# 自检:
ssh -p 2222 shuo@127.0.0.1 # 这里必须能登录成功
1. VPS:确认允许对外监听与转发
# 在 VPS
sed -i 's/^#\?GatewayPorts.*/GatewayPorts clientspecified/' /etc/ssh/sshd_config
grep -q '^AllowTcpForwarding' /etc/ssh/sshd_config && sed -i 's/^AllowTcpForwarding.*/AllowTcpForwarding yes/' /etc/ssh/sshd_config || echo 'AllowTcpForwarding yes' >> /etc/ssh/sshd_config
systemctl reload ssh || systemctl reload sshd || service ssh reload
sshd -T | egrep 'gatewayports|allowtcpforwarding'
# 期望输出:
# gatewayports clientspecified
# allowtcpforwarding yes
放行端口(如已放行可跳过):
ufw allow 2333/tcp 2>/dev/null || true
firewall-cmd --add-port=2333/tcp --permanent && firewall-cmd --reload 2>/dev/null || true
2. VPS 本机自测(打通全链路)
开一个新的 VPS 终端:
# 在 VPS
ss -lntp | grep :2333
# 期望:LISTEN ... 0.0.0.0:2333 ... sshd
ssh -v -p 2333 shuo@127.0.0.1
# 期望:可以登入到 WSL(看到 WSL 的欢迎信息)
- 若这里能登录,而你在外网仍失败 ⇒ 是安全组/防火墙/ISP阻断,继续检查云防火墙和本机出网。
- 若这里也失败,继续第 4 步看日志。
3. 看两端日志精准定位
VPS:
# 尝试一次 ssh -p 2333 ... 之后立即看
journalctl -u ssh -n 50 --no-pager | tail -n 50
# 常见报错:
# "connect_to 127.0.0.1 port 2222: failed: Connection refused"
# => 说明 WSL 的 2222 没开好(回到步骤0)
WSL:
# 连接一次后查看
sudo journalctl -u ssh -n 50 --no-pager | tail -n 50
# 若无任何记录,说明请求没到 WSL(VPS 侧转发失败/未监听 0.0.0.0)
4. 外网再次测试
# 你的 Mac/其它外网机器
ssh -p 2333 shuo@107.174.102.179
5. 稳定化(通过后再做)
# 在 WSL
sudo apt update && sudo apt install -y autossh
autossh -M 20000 -N -f -R 0.0.0.0:2333:127.0.0.1:2222 root@107.174.102.179
持久化操作
1:WSL 开启 systemd
# /etc/wsl.conf
[boot]
systemd=true
在 Windows 里执行:
wsl --shutdown
2:安装 autossh
sudo apt update && sudo apt install -y autossh
3:建立免密(如已配置可跳过)
ssh-keygen -t ed25519 -N "" -f ~/.ssh/id_ed25519
ssh-copy-id -i ~/.ssh/id_ed25519.pub root@107.174.102.179
4:创建用户级 systemd 服务
# ~/.config/systemd/user/wsl-revtunnel.service
[Unit]
Description=Reverse SSH tunnel to VPS
After=network-online.target
Wants=network-online.target
[Service]
ExecStart=/usr/bin/autossh -M 20000 -N -o "ServerAliveInterval=60" -o "ServerAliveCountMax=3" -o "ExitOnForwardFailure=yes" -o "StrictHostKeyChecking=accept-new" -R 0.0.0.0:2333:127.0.0.1:2222 root@107.174.102.179
Restart=always
RestartSec=5
[Install]
WantedBy=default.target
5:允许用户服务在无人登录时运行(一次)
sudo loginctl enable-linger shuo
6:启用并立即启动
systemctl --user daemon-reload
systemctl --user enable --now wsl-revtunnel.service
systemctl --user status wsl-revtunnel.service
之后的行为
- WSL 重启后:systemd 会自动拉起该服务,隧道自动恢复;你可直接从外网连:
ssh -p 2333 shuo@107.174.102.179
- Windows 重启后:WSL 默认不自启。若想开机即生效,在 Windows 任务计划里加一条“开机运行”任务唤醒 WSL,例如(以发行版名
Ubuntu-22.04为例):
schtasks /Create /TN "WSL-Autostart-Ubuntu-22.04" /SC ONSTART /RU SYSTEM /RL HIGHEST /TR "wsl -d ""Ubuntu-22.04"" -- systemctl --user start wsl-revtunnel.service" /F
快速自检
# VPS:应为 0.0.0.0 监听
ss -lntp | grep :2333
# WSL:服务应为 active (running)
systemctl --user status wsl-revtunnel.service
Kadıköy food tour Efficient booking process and confirmation. https://thefreshymarketplace.com/?p=35016
Phgoldencasino, huh? Not my usual jam, but I can see the appeal. It’s got a vibe. Could be a good shout if you’re feeling lucky. Check their offers at phgoldencasino
Bong88org is my go-to when the main site is acting up. Always a smooth experience, no lag or weird glitches. Trust me, it’s a lifesaver! bong88org
Okay, so tried Bongvip. Pretty straightforward. Good selection of games especially Asian focused ones. Nothing groundbreaking, but a solid option if you’re looking for something new. Check’em out. bongvip
Online gaming can be fun, but always remember responsible play! Seeing platforms like BossJL prioritize quick verification is a good sign. Considering a bossjl app download for easy access – just stay mindful of your limits! 😉
Alright, so 555wincom is alright. Site navigation is alright. You know what i mean? If you are looking for a simple game to play, just give them a shot: 555wincom
Need a quick access to 555win? 555winlogin is a good alternative link. Haven’t had any issues with it so far. Check it out man! : 555winlogin
Gotta say, 55win33 aint bad at all. The interface is slick, withdrawal were fast. Worth taking a shot, in my opinion. Check them out here man! : 55win33
Considering a new betting script and meritkingbahisscript looks interesting. Gotta research it properly before diving in. Anyone have experience with this? Check it out here: meritkingbahisscript
Saw youwincasinoinstagram on social media. Their posts are actually pretty cool! Checking them out now. Hope to win maybe! Head over and take a look: youwincasinoinstagram
Alright folks, giving ’77betgame’ a shot! Let’s see if it lives up to the hype. Need a new place to try my luck! Hoping for some wins! Ready to bet at: 77betgame
37JLCasino is where I’ve been spending my nights! Great variety of games and the bonuses are awesome. Don’t miss out on the fun 37jlcasino.
37JLLogin makes it so simple to jump into the game. No more waiting around! One click and I’m ready to win. Easy as pie 37jllogin.
Okay, so I checked out 66winbet and gotta say, the site’s pretty slick. Easy to navigate and the games are actually fun. Definitely worth a look if you’re trying to find a new spot to play. Give 66winbet a shot, you might be surprised!
Just stumbled upon 797979, and the website looks tempting! Is worthy? Lets give it a try. 797979
Luxebetlogin caught my attention due to its sleek interface. The betting process is straightforward, and I appreciate the various options available. Don’t wait! Jump on luxebetlogin right away.
af777slot is great if you like slots. They have a ton of them. The site is easy to use and I haven’t run into any problems depositing or withdrawing. Have a look at af777slot!
26a… Feels fresh, a lot of new markets available compared to other sites that I have used in the past. All the information you need here: 26a
Alright gamers, anyone given w577game a shot? Looks kinda interesting. See what it’s all about here: w577game
Just tried 3patticrown111, and gotta say, it’s pretty slick! Easy to navigate and the games are fun. Definitely worth checking out if you’re looking for a new place to play. Check it out here: 3patticrown111
Brapub login is straight forward, no hassle. That’s what I’m talking about. Take a peek: brapub login
df99 is okay, but I wish it had a better interface. I’m still giving it a try thought. See it here: df99
Fiv88 seems to be decent. The odds aren’t bad and the site is kinda easy to use. Check it out y’all: fiv88