再见TeamViewer,5分钟自建急速远程桌面服务器

TeamViewer确实非常好用,但是有时会被误识别为商业用户,解决起来非常麻烦。
如果你有一台自己的公网服务器的话,完全可以自己搭建远程桌面服务。

这里我们使用frp内网穿透配上Windows自带的远程桌面,windows自带远程桌面大家都知道,显示适配好、速度非常快,1Mbps小水管的服务器都能流畅远控。

对于我来说还有个优点,基于windows系统用户的远控,一个用户同时只能连接一个客户端,安全性和私密性比较高。

微软的RDP 是一个公开的协议,是在协议级别的远程控制传输,变化了哪点传哪点,有时候传的是描述数据,比如显示一个框,RDP远程桌面并不真的传输一个窗口图像,而是传输一个窗口的属性,然后由客户端绘制,其它控制软件都是把图像传过来, 只能压缩图片等试工提高速度 ,但JPG本来就是经过压缩的所有提高速度不明显,而远程桌面这织需要输入一个窗口属性 如 大小 颜色,位置等,这些数据很少,客户端通过这些数据再绘制窗口,而不需要把它当图片传输,当然有些还是需要传输图片的,如果桌面背景图等,所有远程桌面在默认设置时,会自动禁止显示远式桌面背景。
Windows自带的远程连接,使用的RDP协议,这个只有微软玩的转了。

服务器设置

下载解压frp

wget https://github.com/fatedier/frp/releases/download/v0.25.0/frp_0.25.0_linux_amd64.tar.gz

tar -zxvf frp_0.25.0_linux_amd64.tar.gz

编辑frps.ini配置

[common]
bind_port = 7000
log_file = ./frps.log
log_level = info
log_max_days = 3

max_pool_count = 50

subdomain_host = 213.name

启动frps服务端

nohup ./frps &

注意防火墙要开启7000和3389端

Windows客户端设置

第一步:设置windows用户密码
第二步:开启远程桌面服务

右键“此电脑” > 属性 > 远程设置

第三步:下载解压Windows版的frp

https://github.com/fatedier/frp/releases/download/v0.25.0/frp_0.25.0_windows_amd64.zip

第四步:编辑frpc.ini配置文件
[common]
server_addr = 服务器IP
server_port = 7000

[RDP]
type = tcp
local_ip = 0.0.0.0
local_port = 3389
remote_port = 3389
第五步(可跳过):开启frpc客户端测试
第六步:注册frp为系统服务器

借助 winsw 工具可以将frpc注册为windows系统中的服务。
https://github.com/kohsuke/winsw/releases/tag/winsw-v2.1.2
下载winsw最新版,为了方便将其重命名为winsw.exe, 将该文件和frpc.exe放在一起,然后新建winsw.xml写入以下内容:

<service>
    <id>frp</id>
    <name>frp</name>
    <description>用frp发布本地电脑网站到外网</description>
    <executable>frpc</executable>
    <arguments>-c frpc.ini</arguments>
    <logmode>reset</logmode>
</service>

按住Ctrl点击右键打开powershell,
输入命令提权

$loc = (Get-Location ).Path
Start-Process powershell.exe -Verb runas -ArgumentList “-NoExit”,”-Command”,”& {cd $loc }”

然后执行winsw install注册服务
按win+R后执行services.msc进入到服务列表页面找到frp服务。启动并按照下图设置

至此大功告成,打开“远程桌面连接”,输入服务器的域名或IP、账号密码即可体验丝滑的远程桌面体验。

我使用上海节点的阿里云服务器,甚至感觉不出自己在远程使用电脑

28 条评论

[/0o0] [..^v^..] [0_0] [T.T] [=3-❤] [❤.❤] [^v^] [-.0] [!- -] [=x=] [→_→] [><] 更多 »
昵称
  1. eddie Google Chrome 84 Google Chrome 84 Windows 10 Windows 10

    这个服务能监测到是否启动成功吗,如果因网络问题启动失败,会不会重试?

    1. 鸽子 鸽子 Google Chrome 85 Google Chrome 85 Windows 10 Windows 10

      可以自己写个守护进程脚本

  2. 佚名 Google Chrome 84 Google Chrome 84 Windows 10 Windows 10

    爬梯子下载也很慢 有没有别的下载的办法

    1. 鸽子 鸽子 WebView 4 WebView 4 Android 10 Android 10

      不需要梯子

  3. Fern4nd0 Google Chrome 84 Google Chrome 84 Windows 10 Windows 10

    没啥毛病,不提权直接powershell里winsw install也是可以的,顺便一说不知道为啥帖子里winsw github链接404了,补一个新的https://github.com/winsw/winsw最新版刚试过搭建成功

    1. 鸽子 鸽子 Google Chrome 84 Google Chrome 84 Windows 10 Windows 10

      感谢补链

  4. Fern4nd0 Google Chrome 84 Google Chrome 84 Windows 10 Windows 10

    powershell那一段出错所在位置 行:1 字符: 63
    + … art-Process powershell.exe -Verb runas -ArgumentList -NoExit,-Command …
    + ~
    参数列表中缺少参量。
    所在位置 行:1 字符: 72
    + … ss powershell.exe -Verb runas -ArgumentList -NoExit,-Command,& {cd $l …
    + ~
    参数列表中缺少参量。
    所在位置 行:1 字符: 73
    + … s powershell.exe -Verb runas -ArgumentList -NoExit,-Command,& {cd $lo …
    + ~
    不允许使用与号(&)。& 运算符是为将来使用而保留的;请用双引号将与号引起来(“&”),以将其作为字符串的一部分传递。
    + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingArgument

  5. gx777 Google Chrome 83 Google Chrome 83 Windows 10 Windows 10

    延迟还好吗?

    1. 鸽子 鸽子 Google Chrome 80 Google Chrome 80 Windows 10 Windows 10

      看你宽带和操作的画面啊,日常操作没问题,看视频肯定卡

  6. 2broear Google Chrome 80 Google Chrome 80 Windows 10 Windows 10

    太干了,家庭版不支持远程,搞tm半天..

    1. 鸽子 鸽子 Google Chrome 79 Google Chrome 79 Windows 10 Windows 10

      淘宝可以买升专业版的激活码

  7. 2broear Google Chrome 80 Google Chrome 80 Windows 10 Windows 10

    [root@iZwz9a9uyf6zq3e2x8nimbZ ~]# nohup ./frps &
    [1] 32374
    nohup: ignoring input and appending output to ‘nohup.out’
    nohup: failed to run command ‘./frps’: No such file or directory
    [1]+ Exit 127 nohup ./frps

    1. 鸽子 鸽子 Google Chrome 79 Google Chrome 79 Windows 10 Windows 10

      frps服务端你都没下载怎么运行..

      1. 2broear Google Chrome 80 Google Chrome 80 Windows 10 Windows 10

        wget也解压了 [..^v^..]

      2. 2broear Google Chrome 80 Google Chrome 80 Windows 10 Windows 10

        /root/frp_0.25.0_linux_amd64/

        1. 鸽子 鸽子 Google Chrome 79 Google Chrome 79 Windows 10 Windows 10

          那你这样执行/root/frp_0.25.0_linux_amd64/frps

      3. 2broear Google Chrome 80 Google Chrome 80 Windows 10 Windows 10

        可以了哈哈—

  8. 2broear Google Chrome 80 Google Chrome 80 Windows 10 Windows 10

    在哪启动frps服务端》

    1. 鸽子 鸽子 Google Chrome 79 Google Chrome 79 Windows 10 Windows 10

      你的服务器上啊

      1. 2broear Google Chrome 80 Google Chrome 80 Windows 10 Windows 10

        不是,提示路径不对,默认在root

        1. 鸽子 鸽子 Google Chrome 79 Google Chrome 79 Windows 10 Windows 10

          ROOT也没问题的啊,你把报错贴上来

  9. 大白鲨 Google Chrome 80 Google Chrome 80 Windows 10 Windows 10

    我解决了,坑真的不少,这两天写篇博客

  10. 大白鲨 Google Chrome 80 Google Chrome 80 Windows 10 Windows 10

    目前发现的原因是winsw status:stopped,解决方法还没找到,winsw的log显示2020/03/11 23:19:44 [W] [service.go:82] login to server failed: dial tcp 127.0.0.1:7000: connectex: No connection could be made because the target machine actively refused it.
    dial tcp 127.0.0.1:7000: connectex: No connection could be made because the target machine actively refused it.

    1. 鸽子 鸽子 Mozilla Compatible Mozilla Compatible iPhone iOS 13.3 iPhone iOS 13.3

      应该是你frp配置没搞好

  11. 大白鲨 Google Chrome 80 Google Chrome 80 Windows 10 Windows 10

    我微信Zed_Wong,有机会探讨一下吗

  12. 大白鲨 Google Chrome 80 Google Chrome 80 Windows 10 Windows 10

    兄弟,我服务器端口也开了,远程机的本地端口也开了,还是没成功

  13. ysk.fun Google Chrome 69 Google Chrome 69 Windows 10 Windows 10

    用毛子版的TV就好了,有啥麻烦的?

    1. 鸽子 鸽子 Google Chrome 77 Google Chrome 77 Windows 10 Windows 10

      关键是微软的RDP比其他远程桌面都好用啊