centos7.9.2009 yum安装xrdp报错解决:GPG key retrieval failed

[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(推荐)

这是最直接和有效的方法。

  1. 移除现有的可能有问题或残缺的 EPEL 配置:

    sudo yum remove epel-release -y
    sudo rm -f /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 # 强制删除残留的无效密钥文件
    
  2. 清理 yum 缓存:

    sudo yum clean all
    
  3. 重新安装 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
    
  4. 再次尝试安装 xrdp:

    sudo yum install xrdp -y
    

    这次应该可以成功,因为新的 epel-release 包已经正确安装了 GPG 密钥。


方法二:手动导入 GPG 密钥(如果方法一无效)

如果出于某种原因您无法重新安装 epel-release,可以尝试手动下载并导入密钥。

  1. 手动下载 GPG 密钥文件:

    sudo curl -o /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7
    
  2. 将密钥导入 RPM 数据库:

    sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
    
  3. 再次运行安装命令:

    sudo yum install xrdp -y
    

安装成功后的步骤

xrdp 安装完成后,您还需要启动服务并设置开机自启:

  1. 启动 xrdp 服务:

    sudo systemctl start xrdp
    
  2. 设置 xrdp 服务开机自启:

    sudo systemctl enable xrdp
    
  3. (重要)配置防火墙:
    xrdp 默认使用 3389/tcp 端口。如果您的防火墙 (firewalld) 是开启的,您需要放行此端口。

    sudo firewall-cmd --permanent --add-port=3389/tcp
    sudo firewall-cmd --reload
    

完成以上步骤后,您就可以使用 Windows 自带的远程桌面连接 (mstsc.exe) 或其他 RDP 客户端来连接您的 CentOS 桌面了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

学亮编程手记

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值