首页 » Linux » 使用Windows远程桌面连接CentOS7中xrdp0.9的黑屏问题

使用Windows远程桌面连接CentOS7中xrdp0.9的黑屏问题

 
文章目录

CentOS7中的vncserver和xrdp都发生了变化,vncserver的配置文件连位置都改了,xrdp只是版本的升级,改动不算大多,加上一直个人喜欢用xrdp(配置简单,即装即用),于是开始在CentOS7中安装xrdp。

一、安装

1、安装好桌面环境,通过yum groupistall安装即可,有几个不同的组可选,详细的可以通过yum grouplist和yum groupinfo来查看。
2、安装epel-release,由于默认的仓库里没有xrdp的包,要想通过yum安装需要先安装EPEL的软件仓库

yum install epel-release -y

3、使用安装xrdp

yum install xrdp -y

二、配置

xrdp的配置几乎不需要任何改动就可以正常允许了,安装完成后通过systemctl start xrdp启动即可使用了,同时记得放开对应防火墙端口,默认3389。
如果需要修改默认端口,请修改配置文件/etc/xrdp/xrdp.ini中[globals]部分的port=3389。
使用xrdp有个问题,xrdp实际上是调用VNC来运行远程桌面的,而每次的连接xrdp的时候都会重新启动一个Xvnc的进程并开启一个新的桌面,如果想要访问之前的桌面,就需要修改配置文件中最后部分

[xrdp1]
name=sesman-Xvnc
lib=libvnc.so
username=ask
password=ask
ip=127.0.0.1
port=-1
delay_ms=2000

将port=-1改成port=ask-1,修改过后需要重启xrdp服务。
这样在每次连接的时候,手动指定要连接VNC端口了(默认是从5910开始,依次递增),如果想知道上次的端口号到多少了,可以通过netstat -tunlp查看监听端口。

三、使用

使用Windows的远程桌面连接(mstsc)连接到CentOS7的xrdp,如果修改了端口需要在IP后面加上":[端口号]",如192.168.0.100:3390。
如果服务器启动正常,防火墙没问题,应该能看到以下画面了:
xrdp
接下来就是输入帐号密码登录,如果需要连接之前的桌面,在port部分输入监听端口即可。

四、故障

正常情况下应该是稍等一会就能看到漂亮的GNOME3的桌面了,但是我却发现一直停留在黑屏界面,于是查看日志
xrdp.log

[[email protected] ~]# cat /var/log/xrdp.log
[20160818-09:41:22] [INFO ] A connection received from: 192.168.0.203 port 10231
[20160818-09:41:22] [INFO ] An established connection closed to endpoint: 192.168.0.203:10231 - socket: 8
[20160818-09:41:22] [INFO ] An established connection closed to endpoint: NULL:NULL - socket: 7
[20160818-09:41:22] [CORE ] WARNING: Invalid x.509 certificate path defined, default path will be used: /etc/xrdp/cert.pem
[20160818-09:41:22] [WARN ] Invalid X.509 certificate path defined, default path will be used: /etc/xrdp/key.pem
[20160818-09:41:22] [INFO ] An established connection closed to endpoint: NULL:NULL - socket: 8
[20160818-09:41:22] [ERROR] Listening socket is in wrong state we terminate listener
[20160818-09:41:22] [INFO ] A connection received from: 192.168.0.203 port 10232
[20160818-09:41:22] [INFO ] An established connection closed to endpoint: 192.168.0.203:10232 - socket: 8
[20160818-09:41:22] [INFO ] An established connection closed to endpoint: NULL:NULL - socket: 7
[20160818-09:41:22] [CORE ] WARNING: Invalid x.509 certificate path defined, default path will be used: /etc/xrdp/cert.pem
[20160818-09:41:22] [WARN ] Invalid X.509 certificate path defined, default path will be used: /etc/xrdp/key.pem
[20160818-09:41:22] [DEBUG] xrdp_000008e8_wm_login_mode_event_00000001
[20160818-09:41:23] [WARN ] local keymap file for 0x0804 found and dosen't match built in keymap, using local keymap file
[20160818-09:41:27] [DEBUG] returnvalue from xrdp_mm_connect 0
[20160818-09:41:29] [INFO ] The following channel is allowed: rdpdr (0)
[20160818-09:41:29] [INFO ] The following channel is allowed: rdpsnd (1)
[20160818-09:41:29] [INFO ] The following channel is allowed: cliprdr (2)
[20160818-09:41:29] [INFO ] The following channel is allowed: drdynvc (3)
[20160818-09:41:29] [DEBUG] The allow channel list now initialized for this session
[20160818-09:41:29] [DEBUG] xrdp_mm_connect_chansrv: chansrvconnect successful
[20160818-09:41:29] [INFO ] An established connection closed to endpoint: 127.0.0.1:3350 - socket: 11

xrdp-sesman.log

[[email protected] ~]# cat /var/log/xrdp-sesman.log
[20160818-09:40:13] [WARN ] [init:46] libscp initialized
[20160818-09:40:13] [CORE ] starting sesman with pid 937
[20160818-09:40:14] [INFO ] listening...
[20160818-09:41:27] [INFO ] A connection received from: 127.0.0.1 port 35755
[20160818-09:41:27] [INFO ] scp thread on sck 8 started successfully
[20160818-09:41:27] [INFO ] ++ created session (access granted): username root, ip 192.168.0.203:10232 - socket: 8
[20160818-09:41:27] [INFO ] starting Xvnc session...
[20160818-09:41:27] [INFO ] An established connection closed to endpoint: NULL:NULL - socket: 9
[20160818-09:41:27] [INFO ] An established connection closed to endpoint: NULL:NULL - socket: 9
[20160818-09:41:27] [INFO ] An established connection closed to endpoint: NULL:NULL - socket: 9
[20160818-09:41:27] [INFO ] An established connection closed to endpoint: NULL:NULL - socket: 7
[20160818-09:41:27] [INFO ] An established connection closed to endpoint: 127.0.0.1:35755 - socket: 8
[20160818-09:41:27] [INFO ] An established connection closed to endpoint: 127.0.0.1:35755 - socket: 8
[20160818-09:41:27] [ERROR] env_set_user: error creating .vnc dir
[20160818-09:41:27] [INFO ] Xvnc :10 -geometry 1364x768 -depth 8 -rfbauth /root/.vnc/sesman_root_passwd -bs -nolisten tcp -localhost -dpi 96
[20160818-09:41:28] [INFO ] starting xrdp-sessvc - xpid=2284 - wmpid=2283

断开连接后
xrdp.log增加

[20160818-09:43:20] [INFO ] An established connection closed to endpoint: NULL:NULL - socket: 8
[20160818-09:43:20] [DEBUG] xrdp_mm_module_cleanup
[20160818-09:43:20] [DEBUG] VNC mod_exit
[20160818-09:43:20] [INFO ] An established connection closed to endpoint: 127.0.0.1:5910 - socket: 12
[20160818-09:43:20] [INFO ] An established connection closed to endpoint: 109.112.47.46:12148 - socket: 13
[20160818-09:43:20] [ERROR] Listening socket is in wrong state we terminate listener

看上去似乎有[ERROR]

对比下成功连接的LOG
xrdp.log

[20160818-09:46:59] [INFO ] A connection received from: 192.168.0.203 port 10270
[20160818-09:46:59] [INFO ] An established connection closed to endpoint: 192.168.0.203:10270 - socket: 8
[20160818-09:46:59] [INFO ] An established connection closed to endpoint: NULL:NULL - socket: 7
[20160818-09:46:59] [CORE ] WARNING: Invalid x.509 certificate path defined, default path will be used: /etc/xrdp/cert.pem
[20160818-09:46:59] [WARN ] Invalid X.509 certificate path defined, default path will be used: /etc/xrdp/key.pem
[20160818-09:46:59] [INFO ] An established connection closed to endpoint: NULL:NULL - socket: 8
[20160818-09:46:59] [ERROR] Listening socket is in wrong state we terminate listener
[20160818-09:46:59] [INFO ] A connection received from: 192.168.0.203 port 10271
[20160818-09:46:59] [INFO ] An established connection closed to endpoint: 192.168.0.203:10271 - socket: 8
[20160818-09:46:59] [INFO ] An established connection closed to endpoint: NULL:NULL - socket: 7
[20160818-09:46:59] [CORE ] WARNING: Invalid x.509 certificate path defined, default path will be used: /etc/xrdp/cert.pem
[20160818-09:46:59] [WARN ] Invalid X.509 certificate path defined, default path will be used: /etc/xrdp/key.pem
[20160818-09:46:59] [DEBUG] xrdp_000009f0_wm_login_mode_event_00000001
[20160818-09:46:59] [WARN ] local keymap file for 0x0804 found and dosen't match built in keymap, using local keymap file
[20160818-09:47:04] [DEBUG] returnvalue from xrdp_mm_connect 0
[20160818-09:47:07] [INFO ] The following channel is allowed: rdpdr (0)
[20160818-09:47:07] [INFO ] The following channel is allowed: rdpsnd (1)
[20160818-09:47:07] [INFO ] The following channel is allowed: cliprdr (2)
[20160818-09:47:07] [INFO ] The following channel is allowed: drdynvc (3)
[20160818-09:47:07] [DEBUG] The allow channel list now initialized for this session
[20160818-09:47:07] [DEBUG] xrdp_mm_connect_chansrv: chansrvconnect successful
[20160818-09:47:07] [INFO ] An established connection closed to endpoint: 127.0.0.1:3350 - socket: 11

xrdp-sesman.log

[20160818-09:47:04] [INFO ] A connection received from: 127.0.0.1 port 35757
[20160818-09:47:04] [INFO ] scp thread on sck 8 started successfully
[20160818-09:47:05] [INFO ] ++ created session (access granted): username root, ip 192.168.0.203:10271 - socket: 8
[20160818-09:47:05] [INFO ] starting Xvnc session...
[20160818-09:47:05] [INFO ] An established connection closed to endpoint: NULL:NULL - socket: 9
[20160818-09:47:05] [INFO ] An established connection closed to endpoint: NULL:NULL - socket: 9
[20160818-09:47:05] [INFO ] An established connection closed to endpoint: NULL:NULL - socket: 9
[20160818-09:47:05] [INFO ] An established connection closed to endpoint: 127.0.0.1:35757 - socket: 8
[20160818-09:47:05] [INFO ] An established connection closed to endpoint: NULL:NULL - socket: 7
[20160818-09:47:05] [INFO ] An established connection closed to endpoint: 127.0.0.1:35757 - socket: 8
[20160818-09:47:05] [ERROR] env_set_user: error creating .vnc dir
[20160818-09:47:05] [INFO ] Xvnc :11 -geometry 1364x768 -depth 16 -rfbauth /root/.vnc/sesman_root_passwd -bs -nolisten tcp -localhost -dpi 96
[20160818-09:47:05] [INFO ] starting xrdp-sessvc - xpid=2548 - wmpid=2547

断开连接后,xrdp.log增加

[20160818-09:48:45] [INFO ] An established connection closed to endpoint: NULL:NULL - socket: 8
[20160818-09:48:45] [DEBUG] xrdp_mm_module_cleanup
[20160818-09:48:45] [DEBUG] VNC mod_exit
[20160818-09:48:45] [INFO ] An established connection closed to endpoint: 127.0.0.1:5911 - socket: 12
[20160818-09:48:45] [INFO ] An established connection closed to endpoint: 109.112.47.46:12148 - socket: 13
[20160818-09:48:45] [ERROR] Listening socket is in wrong state we terminate listener

结果表明,LOG中的[ERROR]对问题没有实质性的影响,成功和失败的日志中唯一不同点在于xrdp-sesman.log中
失败的:

[20160818-09:41:27] [INFO ] Xvnc :10 -geometry 1364x768 -depth 8 -rfbauth /root/.vnc/sesman_root_passwd -bs -nolisten tcp -localhost -dpi 96

成功的:

[20160818-09:47:05] [INFO ] Xvnc :11 -geometry 1364x768 -depth 16 -rfbauth /root/.vnc/sesman_root_passwd -bs -nolisten tcp -localhost -dpi 96

没错,仅仅一个数字的差别,即 -depth 【8】和【16】,表示颜色深度,但是在Win7上远程桌面设置中我明明分别设置的是【增强色(15位)】和【增强色(16位)】,没有设置8位,也没有8位可以选。难道这就是问题所在?经进步一测试,在XP的远程桌面客户端(支持256色,即8位)版本中,使用256色连接依然黑屏,xrdp-sesman的日志中看到的也是-depth 8,看来在使用低于16位色深进行远程桌面连接时即会黑屏。

五、总结

在远程桌面客户端使用低于16位色深连接CentOS7(Gnome3)中的xrdp时,会出现黑屏的情况,至于问题的关键是在GNOME3上,还是xrdp还是Xvnc中,目前还不得而知,有待进一步研究。

======

后记

经过大量测试,初步断定问题应该是在xrdp上,测试结果如下:
GNOME3+xrdp0.9:使用16位色连接正常,15位色及以下黑屏
KDE+xrdp0.9:色深对连接成败无影响,但是KDE下分辨率没能自适应
Xfce4+xrdp0.9:与GNOME一样,16位色以上才正常,15位色及以下有报错
Xfce4+xrdp0.6:色深对连接成败无影响,但是在第一次连接成功之后退出再次连接失败,需要重启xrdp服务才行,Github上有关于此问题的讨论,为xrdp的BUG,详见https://github.com/neutrinolabs/xrdp/issues/284

原文链接:使用Windows远程桌面连接CentOS7中xrdp0.9的黑屏问题,转载请注明来源!

0