以win10/win11系统为例下载客户端访问异地远程的ssh服务为例,
假设域名为:quwei.de
进入cloudflare官方控制台管理cloudflared tunnels的隧道面板内 已发布应用程序路由 选顶卡
添加一条 ssh.quwei.de 子域,服务类型选ssh或tcp,url内填localhost:22
或127.0.0.1:22 保存即可。
使用cloudflared tunnels可以架设内网访问服务器,
通常用的是http访问页面没问题,这个简单,直接可以浏览器访问。
但是要穿透ssh/rdp/samba/tcp等,还需要你在访问者的本地安装cloudflared客户端,
https://github.com/cloudflare/cloudflared/releases/
推荐下载和你cloudflared服务端一样的版本,比如,我的是2025.8.1版本
下载适用于 Windows 的 cloudflared-windows-amd64.exe
然后在cmd执行转发命令:
cloudflared-windows-amd64.exe access ssh --hostname ssh.quwei.de -url localhost:222
-url localhost:222 的作用是转到本机器的222端口,方便用任意ssh工具连接管理
ssh -p 222 root@localhost
别的什么ssh工具,主机填localhost端口222,
登录帐号和钥匙还是填你之前服务器创建的用户。
如果发生如下错误:
ERR failed to connect to origin error="websocket: bad handshake" originURL=https://ssh.quwei.de
产生的原因,因此前为了方便,添加了通配符子域的*.quwei.de在前,所以后边添的ssh.quwei.de子域是不生效的,默认还是http服务类型。
处理方法:调前ssh子域,
进入cloudflared tunnels面板,进入Zero Trust > 网络 > Tunnels
编辑你创建的隧道项目,
切换到,
“已发布应用程序路由” 选项卡,
通过右侧菜单上移功能,
将你的ssh.quwei.de 提前到 *.quwei.de之前即可。