xRDP实现Linux图形化通过Windows RDP访问Linux远程桌面

xRDP介绍

xRDP(X Remote Desktop Protocol)是一个开源的远程桌面协议实现,基于Microsoft RDP协议,允许用户通过RDP客户端远程访问Linux桌面环境,提供图形化操作体验。‌

安装过程

我这里拿Centos7.9举例,具体其他系统版本请参照其他教程

一、安装GNOME默认桌面环境

CentOS 官方源默认没有 xRDP 包,需先安装 EPEL 扩展源,再安装 XRDP

bash 复制代码
# 安装EPEL扩展源
[root@localhost ~]# yum install -y epel-release
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==============================================================================================================================================
 Package                               Arch                            Version                          Repository                       Size
==============================================================================================================================================
Installing:
 epel-release                          noarch                          7-11                             extras                           15 k
Transaction Summary
==============================================================================================================================================
Install  1 Package
Total download size: 15 k
Installed size: 24 k
Downloading packages:
epel-release-7-11.noarch.rpm                                                                                           |  15 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : epel-release-7-11.noarch                                                                                                   1/1 
  Verifying  : epel-release-7-11.noarch                                                                                                   1/1 
Installed:
  epel-release.noarch 0:7-11                                                                                                                  
Complete!
# 安装GNOME默认桌面环境
yum groupinstall "X Window System" -y
yum group install "GNOME" -y

二、安装xRDP

bash 复制代码
# 安装xRDP
[root@localhost ~]# yum install xrdp -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * epel: d2lzkl7pfhq30w.cloudfront.net
Resolving Dependencies
--> Running transaction check
---> Package xrdp.x86_64 1:0.9.25-2.el7 will be installed
--> Processing Dependency: libImlib2.so.1()(64bit) for package: 1:xrdp-0.9.25-2.el7.x86_64
--> Running transaction check
---> Package imlib2.x86_64 0:1.4.9-8.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==============================================================================================================================================
 Package                         Arch                            Version                                  Repository                     Size
==============================================================================================================================================
Installing:
 xrdp                            x86_64                          1:0.9.25-2.el7                           epel                          463 k
Installing for dependencies:
 imlib2                          x86_64                          1.4.9-8.el7                              epel                          210 k
Transaction Summary
==============================================================================================================================================
Install  1 Package (+1 Dependent package)
Total download size: 674 k
Installed size: 2.8 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/epel/packages/imlib2-1.4.9-8.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 352c64e5: NOKEY--:-- ETA 
Public key for imlib2-1.4.9-8.el7.x86_64.rpm is not installed
(1/2): imlib2-1.4.9-8.el7.x86_64.rpm                                                                                   | 210 kB  00:00:00     
(2/2): xrdp-0.9.25-2.el7.x86_64.rpm                                                                                    | 463 kB  00:00:01     
----------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                         235 kB/s | 674 kB  00:00:02     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Importing GPG key 0x352C64E5:
 Userid     : "Fedora EPEL (7) <epel@fedoraproject.org>"
 Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
 Package    : epel-release-7-11.noarch (@extras)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : imlib2-1.4.9-8.el7.x86_64                                                                                                  1/2 
  Installing : 1:xrdp-0.9.25-2.el7.x86_64                                                                                                 2/2 
  Verifying  : imlib2-1.4.9-8.el7.x86_64                                                                                                  1/2 
  Verifying  : 1:xrdp-0.9.25-2.el7.x86_64                                                                                                 2/2 
Installed:
  xrdp.x86_64 1:0.9.25-2.el7                                                                                                                  
Dependency Installed:
  imlib2.x86_64 0:1.4.9-8.el7                                                                                                                 
Complete!

# 启动Xrdp服务,并设置开机启动
[root@localhost ~]# systemctl enable xrdp --now
Created symlink from /etc/systemd/system/multi-user.target.wants/xrdp.service to /usr/lib/systemd/system/xrdp.service.

# 查看启动状态
[root@localhost ~]# systemctl status xrdp
● xrdp.service - xrdp daemon
   Loaded: loaded (/usr/lib/systemd/system/xrdp.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2026-01-13 15:33:32 CST; 5s ago
     Docs: man:xrdp(8)
           man:xrdp.ini(5)
 Main PID: 56412 (xrdp)
    Tasks: 1
   CGroup: /system.slice/xrdp.service
           └─56412 /usr/sbin/xrdp --nodaemon
Jan 13 15:33:32 localhost.localdomain systemd[1]: Started xrdp daemon.
Jan 13 15:33:32 localhost.localdomain xrdp[56412]: [INFO ] starting xrdp with pid 56412
Jan 13 15:33:32 localhost.localdomain xrdp[56412]: [INFO ] address [0.0.0.0] port [3389] mode 1
Jan 13 15:33:32 localhost.localdomain xrdp[56412]: [INFO ] listening to port 3389 on 0.0.0.0
Jan 13 15:33:32 localhost.localdomain xrdp[56412]: [INFO ] xrdp_listen_pp done

# 设置xRDP使用GNONE,编辑配置文件,添加如下行(端口可自行更改)
[root@localhost ~]# vim /etc/xrdp/xrdp.ini
exec gnome-session

# 重启服务
[root@localhost ~]# systemctl restart xrdp

防火墙自行放通或者关闭,云服务器开通安全组3389(或你自行设置的端口)

三、使用mstsc连接

相关推荐
龙亘川2 小时前
城管住建领域丨市政设施监测功能详解——桥梁运行监测系统(2)、管廊运维监测系统(3)
大数据·运维·人工智能·物联网·政务
LeetCode天天刷2 小时前
1348 推文计数【区间】
java·服务器·windows
2501_920953862 小时前
行业内比较好的6S管理咨询平台
大数据·运维·人工智能
艾莉丝努力练剑2 小时前
【QT】环境搭建收尾:认识Qt Creator
运维·开发语言·c++·人工智能·qt·qt creator·qt5
tianyuanwo2 小时前
解决Anolis/CentOS 8下Python 3.11 SELinux模块缺失:从原理到实战的完整指南
linux·centos·python3.11
小李独爱秋2 小时前
计算机网络经典问题透视:可以通过哪些方案改造互联网,使互联网能够适合于传送音频/视频数据?
运维·服务器·网络协议·计算机网络·音视频
承渊政道2 小时前
Linux系统学习【Linux基础指令以及权限问题】
linux·服务器·学习
一个人听秋雨2 小时前
speedtest-x脚本优化
linux·运维
食咗未2 小时前
Linux SSH工具的使用
linux·网络·测试工具·ssh·远程登陆