redhat/centos 7 远程连接图形化桌面

方法一:rdp

使用xrdp工具,类似windows系统的远程桌面(rdp),需要在服务端安装远程桌面服务

如果你的服务器可以使用阿里的yum源,可以直接使用epel仓库安装,执行以下命令即可

yum -y install epel-release
yum -y install xrdp
yum -y install tigervnc-server

因为Xrdp最终会自动启用VNC,所以必须安装tigervnc-server,否则xrdp无法使用

xrdp 的配置/etc/xrdp/xrpd.ini

启动服务。端口就是rdp服务的默认3389端口,需要firewall放行此端口,或者关闭firewalld服务

systemctl start xrdp
systemcat enable xrdp  --设置开机自启

此时客户端 win + r 输入mstsc,回车输入服务端的ip,通过认证即可访问

 

 

 

 

方法二:vnc

利用方法一中安装的tigervnc-server,直接启用vnc服务,此时默认端口变成5900,不再是3899

启动服务

[root@tomcat1 /]# vncserver --help

usage: vncserver [:<number>] [-name <desktop-name>] [-depth <depth>]
                 [-geometry <width>x<height>]
                 [-pixelformat rgbNNN|bgrNNN]
                 [-fp <font-path>]
                 [-cc <visual>]
                 [-fg]
                 [-autokill]
                 [-noxstartup]
                 [-xstartup <file>]
                 [-fallbacktofreeport]
                 <Xvnc-options>...

       vncserver -kill <X-display>

       vncserver -list

[root@tomcat1 /]# vncserver                                          ////启动服务

New 'tomcat1:2 (root)' desktop is tomcat1:2

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/tomcat1:2.log

[root@tomcat1 /]# vncserver -list                                    ////查看服务的状态,有输出结果代表服务已经起来

TigerVNC server sessions:

X DISPLAY #     PROCESS ID
:2              4915                                                 ////默认端口是5900 :2在客户端连接的时候需要+2 ,意思就是5902
[root@tomcat1 /]#

远程登录图形桌面,此处我用的是vnc-viewer ,官网  https://www.realvnc.com/en/connect/download/viewer/    

上一步的 :2 体现在这里,用默认的端口加上这个数字,就是服务端监听的端口,使用完之后为了安全,可以关闭服务,另外,这一步的密码跟系统用户的密码不一样,是vncpasswd命令生成的

vncpasswd 回车,输入密码,确认密码,回车

[root@tomcat1 /]# vncserver -kill :2
Killing Xvnc process ID 4915
[root@tomcat1 /]#

服务已关闭

ps: 据说,可以把vncserver服务加入系统的systemd管理,但是我按照网上的方法没有成功,后续继续研究

原文地址:https://www.cnblogs.com/augusite/p/14183562.html