系统配置

CentOS Linux release 7.9.2009 (Core)
Windows 自带的远程桌面无法连接 Linux 服务器,解决方案是在 Linux 服务器上安装 xrdp 并进行配置,所需安装如下:

  • GNOME
  • epel-release
  • xrdp

xrdp 安装

  1. GNOME
    检查服务器是否安装图形化桌面 GNOME
1
rpm -qa | grep gnome-desktop

无安装则安装 GNOME

1
yum -y groups install "GNOME Desktop"
  1. xrdp
    yum 基本源中不包含 xrdp 包,因此安装 epel-release 扩展源
1
yum -y install epel-release

安装 xrdp

1
yum -y install xrdp

若显示如下

1
2
 没有可用软件包 xrdp。
错误:无须任何处理

则找到适合自己系统的 xrdp 包,以 x86_64 为例离线安装 xrdp

1
2
wget https://kojipkgs.fedoraproject.org//packages/xrdp/0.9.22.1/3.fc39/x86_64/xrdp-0.9.22.1-3.fc39.x86_64.rpm
yum -y install xrdp-0.9.22.1-3.fc39.x86_64.rpm

如果遇到类似 xrdp-0.9.22.1-2.el7.x86_64 (/xrdp-0.9.22.1-2.el7.x86_64) 需要:libImlib2.so.1 ()(64bit) 的报错,就缺什么安什么

1
2
wget https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/i/imlib2-1.4.9-8.el7.x86_64.rpm
yum -y install imlib2-1.4.9-8.el7.x86_64.rpm

启动 xrdp 并设置开机启动

1
2
systemctl start xrdp
systemctl enable xrdp

关闭防火墙

1
systemctl stop firewalld

至此 xrdp 安装配置完毕
3. 远程连接
远程连接时可能会出现输入用户密码后闪退,先查看报错日志

1
nano home/admin/.xsession-errors
1
2
3
4
5
6
imsettings-check: ): IMSettings-WARNING **: Could not connect: Connection refused

(imsettings-check: ): GLib-GIO-CRITICAL **: g_dbus_proxy_call_sync_internal: assertion 'G_IS_DBUS_PROXY (proxy)' failed
GLib-GIO-Message: Using the 'memory' GSettings backend. Your settings will not be saved or shared with other applications.

** (process: ): WARNING **: Could not make bus activated clients aware of XDG_CURRENT_DESKTOP=GNOME environment variable: Could not connect: Connection refused

报错原因是 anaconda 中的的 dbus_daemo 与 /usr/bin 的 dbus_daemo 冲突,解决方案是将 /usr/bin 先让系统识别

1
sudo nano ~/.bashrc

将原本的环境变量改为

1
export PATH="/usr/bin:/home/admin/anaconda3/bin:$PATH"


更改当前的环境变量

1
source ~/.bashrc

连接成功