情景需求1:在家办公需要连接学校的GPU服务器,除了学校提供的VPN之外还有啥方法
情景需求2:在学校需要连接学校实验室的主机,而这个主机在一个路由器下面(192.168.50.23)
前提:有个云服务器,比如腾讯云,阿里云,华为云等等,90块钱几个月的那种,提供公网IP
云服务器配置:
环境Ubuntu18,64位版本
下载工具
tar -zxvf frp****
cd frp****
设置frps.ini,s指的是服务器端
frps.ini
[common]
bind_port = 15672 # 确保不被占用(1---->65533)
dashboard_port = 7600 # 确保不被占用(1---->65533)
dashboard_user = username # 随便起个名字,可以不写这个
dashboard_pwd = pwd # 可以不写,这俩是浏览器打开设置frp的,没多大卵用
authentication_method = token
token = pwd
./frps -c ./frps.ini
我这里frps_241.ini是自己改的名字,为啥要改呢,因为要穿透GPU服务器(241)和台式机(3070)
客户端:你的笔记本,或者台式机
还是下载frp那个工具,解压后设置
[common]
server_addr = 你的云服务器公网IP
server_port = 15672 # 随便写一个就行了
authentication_method = token
token = pwd
[ssh-241] # 不可以重复,这个241指的是我的gpu服务器
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 20022 #确保不冲突
./frpc -c ./frpc.ini
找到另一台主机,例如手机给ubuntu笔记本开个热点,尝试着用这个笔记本连接Gpu服务器(241)或者连接实验室路由器下面的台式机(3070)
连接241服务器
ssh -oPort=20022 241服务器的用户名@云服务器公网IP
eg: 云服务器ip 125.252.888.999
241服务器的登录名 嘤嘤嘤
ssh -oPort=20022 嘤嘤嘤@125.252.888.999
输入嘤嘤嘤的密码例如 root
OK!
对于设置多个映射,那就在云服务器上添加个frps_other.ini
比如添加个3070
frps_3070.ini
[common]
bind_port = 7000
dashboard_port = 7500
dashboard_user = username
dashboard_pwd = pwd
authentication_method = token
token = pwd
然后3070机器上再配置下frpc.ini
[common]
server_addr = 公网IP
server_port = 7000
authentication_method = token
token = pwd
[ssh-3070]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 6000
参考:
保姆级教程:个人深度学习工作站配置指南
解决 Error starting userland proxy: listen tcp 0.0.0.0:6379: bind: address already in use
内网穿透:frp映射多客户端配置分享