通过ssh连接家中路由器下的linux,通过mstsc连接家中路由器下的windows(一种teamviewer的替代方案)
本质就是转发消息:两个tcp连接,将一个tcp连接中读到的消息不经过任何处理直接写到另一个tcp连接。
通过ssh访问:使用ssh访问,最终所有的消息都转发到家中的ssh端口上
需要借助一台公网的linux主机,例如腾讯云。
重复3、4、5可以用来处理多个ssh连接请求
整个流程:
用户<—-user_connect——>server <=交换数据=> server <——home_connect——-> client <=交换数据=> client <—-ssh—-> ssh
# 如果没有安装go
yum install golang
# 编译
go build server.go common.go
go build client.go common.go
./server -user_port=12345 -home_port=12346
./client -ip=xxx.xxx.xxx.xxx -remote_port=12346 -local_port=22 # local_port默认为22
ssh user@xxx.xxx.xxx.xxx -p 12345
在局域网内可以通过mstsc进行远程桌面连接,mstsc的端口为3389,只要我们将client运行在window上就
可以通过公网ip加端口连接到windows