通过跳板服务器进行内网穿透

发布时间:2026/6/30 9:49:32

通过跳板服务器进行内网穿透 从头配置到可登录关键流程1. 腾讯云 Ubuntu 跳板机准备云服务器公网 IP124.220.19.164安装并启用 SSH 服务安全组放行22/tcp13389/tcp2. 云服务器 SSH 配置编辑sudonano/etc/ssh/sshd_config确保有AllowTcpForwarding remote GatewayPorts clientspecified重启 SSHsudosystemctl restartssh3. 本地 Windows 生成 SSH 密钥在本地 Windows PowerShell 执行ssh-keygen-t ed25519-f$env:USERPROFILE\.ssh\cloud_tunnelGet-Content$env:USERPROFILE\.ssh\cloud_tunnel.pub把输出的整行公钥复制出来。4. 把公钥加到云服务器在云服务器执行sudoadduser --disabled-password--gecostunnelsudomkdir-p/home/tunnel/.sshsudochown-Rtunnel:tunnel /home/tunnel/.sshsudochmod700/home/tunnel/.sshsudobash-ccat /home/tunnel/.ssh/authorized_keys粘贴公钥回车后按Ctrl D再执行sudochowntunnel:tunnel /home/tunnel/.ssh/authorized_keyssudochmod600/home/tunnel/.ssh/authorized_keys5. 本地 Windows 开启远程桌面确认本地 Windows系统为Windows 10 Pro远程桌面已开启3389正常监听检查命令qwinsta netstat-ano|findstr :3389Test-NetConnection127.0.0.1-Port 3389正常应看到rdp-tcp ... 侦听3389 LISTENINGTcpTestSucceeded : True6. 本地 Windows 启动反向 SSH 隧道在本地 Windows PowerShell 执行ssh-NT -i$env:USERPROFILE\.ssh\cloud_tunnel-o ExitOnForwardFailureyes -o ServerAliveInterval60 -o ServerAliveCountMax3 -R 0.0.0.0:13389:127.0.0.1:3389 tunnel124.220.19.164注意这个窗口不要关闭。7. 云服务器验证隧道在云服务器执行ss-lnt|grep13389nc-vz127.0.0.113389正常应看到0.0.0.0:13389在监听succeeded8. 家里电脑连接先测试端口Test-NetConnection124.220.19.164-Port 13389如果TcpTestSucceeded : True再打开远程桌面mstsc填写计算机124.220.19.164:13389用户名\.\admin密码本地 Windows 服务器admin账户密码9. 以后日常使用每次本地 Windows 重启后重新执行第 6 步再从家里电脑用mstsc连接124.220.19.164:13389

相关新闻