[root@localhost ~]# yum install xrdp -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
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 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
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
GPG key retrieval failed: [Errno 14] curl#37 - "Couldn't open file /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7"
这个错误表明您的系统在尝试从 EPEL 仓库安装 xrdp
时,缺少用于验证软件包完整性的 GPG 密钥。EPEL (Extra Packages for Enterprise Linux) 是一个为 RHEL/CentOS 提供高质量附加软件包的仓库。
问题原因:
GPG 密钥文件 /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
丢失或损坏,导致 yum 无法验证从 EPEL 仓库下载的软件包(xrdp
和其依赖 imlib2
)的签名。
解决方案:
您需要重新安装 epel-release
包,它会自动提供正确的 GPG 密钥。
下述方法二奏效——
[root@localhost ~]# sudo curl -o /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1662 100 1662 0 0 1527 0 0:00:01 0:00:01 --:--:-- 1528
[root@localhost ~]# sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
[root@localhost ~]# sudo yum install xrdp -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
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 size: 674 k
Installed size: 2.8 M
Downloading packages:
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!
[root@localhost ~]# lsof -i:3389
[root@localhost ~]# sudo systemctl start xrdp
[root@localhost ~]# lsof -i:3389
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
xrdp 3502 root 11u IPv6 63026 0t0 TCP *:ms-wbt-server (LISTEN)
[root@localhost ~]#
方法一:直接重新安装 epel-release(推荐)
这是最直接和有效的方法。
-
移除现有的可能有问题或残缺的 EPEL 配置:
sudo yum remove epel-release -y sudo rm -f /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 # 强制删除残留的无效密钥文件
-
清理 yum 缓存:
sudo yum clean all
-
重新安装 EPEL 仓库:
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm -y
或者使用
rpm
命令安装:sudo rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
-
再次尝试安装 xrdp:
sudo yum install xrdp -y
这次应该可以成功,因为新的
epel-release
包已经正确安装了 GPG 密钥。
方法二:手动导入 GPG 密钥(如果方法一无效)
如果出于某种原因您无法重新安装 epel-release
,可以尝试手动下载并导入密钥。
-
手动下载 GPG 密钥文件:
sudo curl -o /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7
-
将密钥导入 RPM 数据库:
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
-
再次运行安装命令:
sudo yum install xrdp -y
安装成功后的步骤
xrdp
安装完成后,您还需要启动服务并设置开机自启:
-
启动 xrdp 服务:
sudo systemctl start xrdp
-
设置 xrdp 服务开机自启:
sudo systemctl enable xrdp
-
(重要)配置防火墙:
xrdp 默认使用 3389/tcp 端口。如果您的防火墙 (firewalld
) 是开启的,您需要放行此端口。sudo firewall-cmd --permanent --add-port=3389/tcp sudo firewall-cmd --reload
完成以上步骤后,您就可以使用 Windows 自带的远程桌面连接 (mstsc.exe) 或其他 RDP 客户端来连接您的 CentOS 桌面了。