欢迎光临散文网 会员登陆 & 注册

【无公网IP】在公网环境下Windows远程桌面Ubuntu

2023-07-31 15:18 作者:probezy  | 我要投稿

本篇文章主要介绍在Ubuntu上安装XRDP远程桌面,实现同个局域网内远程桌面Ubuntu,同时解决远程桌面登录蓝屏的问题。

并做内网穿透,使用cpolar内网穿透映射3389端口,生成公网TCP端口地址,实现在公网环境下,远程桌面Ubuntu系统。

【cpolar内网穿透支持http/https/tcp协议,支持永久免费使用,不限制流量,无需公网IP,也不用进入路由器设置,操作简单。】

一、 同个局域网内远程桌面Ubuntu

1. 更新软件仓库

sudo apt updatesudo apt upgrade

Bash

Copy

2. 安装支持包

安装支持包 : Xorg, Xrdp, Xserver, Xfce4 and Mate Packages

sudo apt-get install xorgsudo apt-get install xserver-xorg-coresudo apt-get install xorgxrdp

Bash

Copy

3. 安装XFCE4桌面环境

sudo apt install xfce4 xfce4-goodies xorg dbus-x11 x11-xserver-utils

Bash

Copy

4. 安装XRDP

sudo apt install xrdpsudo systemctl status xrdpsudo systemctl restart xrdp

Bash

Copy

5. 环境设置

5.1 XFCE桌面配置

sudo sed -i.bak '/fi/a #xrdp multiple users configuration \n xfce-session \n' /etc/xrdp/startwm.sh

Bash

Copy

5.2 在配置文件中,加入XFCE会话

echo xfce4-session > ~/.xsession

Bash

Copy

6 重启服务

sudo systemctl restart xrdp

Bash

Copy

7. 查看IP地址

sudo apt install net-tools

Bash

Copy

ifconfig

Bash

Copy

如图:

本例中,获取Ubuntu主机IP为192.168.9.144

8. 使用Windows远程桌面连接

在局域网,找到另一台Windows主机,打开远程桌面连接,输入Ubuntu主机的IP地址,以及用户名密码。

第一次登录时,会显示

点击Use default config按钮,继续。

现在,已经远程桌面连接成功了。

二、公网环境系统远程桌面Ubuntu

在没有公网IP的环境下,要实现远程桌面连接,可以通过cpolar内网穿透来实现,映射3389端口。

1. 注册cpolar账号并安装

1.1. 安装cpolar(通过一键自动安装脚本方式)

curl -L https://www.cpolar.com/static/downloads/install-release-cpolar.sh | sudo bash

Bash

Copy

或 cpolar短链接安装方式:(国外使用)

curl -sL https://git.io/cpolar | sudo bash

Bash

Copy

1.2 向系统添加服务

sudo systemctl enable cpolar

Bash

Copy

1.3 启动cpolar服务

sudo systemctl start cpolar

Bash

Copy

2. 登录cpolar web UI管理界面

在浏览器访问 127.0.0.1:9200,使用cpolar账号密码登录

3. 创建隧道,映射3389端口

登录进入cpolar web UI管理界面后,点击左侧隧道管理——创建隧道,创建一条tcp隧道

  • 隧道名称:xrdp(可自定义,注意不要重复)

  • 协议:tcp(支持http/https/tcp)

  • 本地地址:3389

  • 端口类型:免费用户选择随机临时TCP端口,专业套餐用户可- 配置固定的TCP端口

  • 地址:选择China

隧道创建成功后,点击左侧仪表盘的状态——在线隧道列表,查看xrdp隧道的所生成的公网TCP端口地址,复制下来。
【本例中为http://1.tcp.cpolar.cn:23975】


4. 远程桌面Ubuntu

Windows电脑打开远程桌面连接,输入所生成的公网tcp端口地址,点击连接

点击“是”

输入Ubuntu系统的用户名密码,点击"OK"

需要注意,本文中使用的是免费的cpolar套餐所生成的随机临时公网地址,每隔24小时就会发生变化,且带宽较小。

对于有长期远程桌面需求的用户,建议将cpolar套餐升级到专业套餐,支持配置固定的公网TCP端口,且带宽也会相应的增大,支持更高效便捷的远程桌面连接Ubuntu系统。

【无公网IP】在公网环境下Windows远程桌面Ubuntu的评论 (共 条)

分享到微博请遵守国家法律