How to Install VNC Server on RHEL 8

VNC (Virtual Network Computing) is a popular graphical desktop sharing platform that allows you to network (such as the Internet) remote access, view and control other computers.

VNC using Remote Frame Buffer protocol (the RFB) and according to a client - server Working principle: server share its output (vncserver), the client (vncviewer) is connected to the server. Please note that remote computer must install the desktop environment.

In this article, we will describe how to install and configure VNC Remote Access in the latest version of RHEL 8 Desktop Edition by tigervnc-server program.

Claim:

  • RHEL8, minimum installation
  • RHEL8, the subscription is enabled
  • RHEL8 with a static IP address

Once your RHEL 8 system meets the requirements listed above, you can set it to the VNC server.

Step 1: Wayland Display Manager to disable and enable the X.org

Default desktop environment (DE) is on 1. RHEL 8 GNOME, configured to use the default display manager Wayland. However, Wayland X.org is not as remote as the rendering API. Therefore, you need to configure the system to use X.org display manager.

Use your favorite command line editor to open GNOME Display Manager (GDM) configuration file.

# We /etc/gdm/custom.conf

Then uncomment this line to force the login screen using Xorg.

WaylandEnable=false

Disable Wayland in Gnome

Save the file and close it.

Step 2: VNC server installed in RHEL 8

2. TigerVNC (Tiger Virtual Network Computing) is an open source, widely used graphical desktop sharing system that allows you to remotely control another computer.

# dnf install tigervnc-server tigervnc-server-module

3. Next, a switch to the user to run, and by setting the program to a user using a VNC VNC server password (should be at least six characters), as illustrated in FIG.

Set user VNC password

Now, by running the exit command to switch back to the root account.

$ exit

Step 3 VNC server in RHEL 8

4. In this step, you must configure the server to start TigerVNC to said user on the system display. First, create a file named /etc/systemd/system/[email protected] configuration file, as shown below.

# We /etc/systemd/system/[email protected]

[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/bin/vncserver -autokill %i
ExecStop=/usr/bin/vncserver -kill %i

[Install]
WantedBy=multi-user.target

Save the file and close it.

Before we move further, let us briefly understand how VNC server listens for requests. By default, VNC uses TCP port 5900 + N, where N is a number. If the number is 1, then the VNC server will run on port number 5901 is displayed. This is the port that must be used when connecting from the client to the server.

Step 4: Enable VNC service in RHEL 8

5. To start the VNC service, you need to disable SELinux default execution mode on RHEL 8.

# setenforce 0
# sed -i 's/enforcing/disabled/g' /etc/selinux/config

6. Now reload systemd manager configured to apply the recent changes, then start the VNC service to start automatically when the system boots, and use the following command systemctl check if it is up and running.

# systemctl daemon-reload
# systemctl start vncserver@:1
# systemctl status vncserver@:1
# systemctl enable vncserver@:1

7. At this point, VNC service is up and running, using the netstat command to verify the VNC server is listening on TCP port 5901.

# netstat -tlnp

Check the VNC listening port

8. Next, open the default port 5901 system running firewall service, as shown in FIG. This allows access to the VNC server from the client.

# firewall-cmd --permanent --add-port=5901/tcp
# firewall-cmd --reload

Step 5: connect to the VNC server through a VNC client

9. Now it's time to look at how to access VNC server from a client. By default, VNC is not a secure system, which means that your connection is not encrypted at all. But you can use a technique called SSH tunnel to protect the connection from the client to the server, as described below.

Remember, you need to configure SSH password is no identity between the server and the client computer verification, in order to increase the trust between the two Linux systems.

然后在Linux客户端计算机上打开终端窗口并运行以下命令创建到VNC服务器的SSH隧道(不要忘记更改身份文件(~/.ssh/rhel8)和IP地址(192.168.56.110)的路径的相应服务器):

$ ssh -i ~/.ssh/rhel8 -L 5901:127.0.0.1:5901 -N -f -l tecmint 192.168.56.110

10.创建SSH隧道后,您可以在客户端计算机上安装vncviewer客户端,例如TigerVNC Viewer。

11.安装完成后,运行VNC客户端,指定地址localhost:5901以连接到显示1,如下所示。

$ vncviewer localhost:5901
或者
$ vncviewer 127.0.0.1:5901

或者,从系统菜单中搜索并打开VNC客户端程序,然后输入上面的地址,然后单击“连接 Connect”,如以下屏幕截图所示。

打开VNC客户端

 如果连接成功,系统将提示您输入先前在步骤2,第3点中创建的VNC登录密码。提供该密码并单击“确定”继续。

输入VNC登录密码

成功进行VNC服务器身份验证后,您将看到远程RHEL 8系统桌面界面。 单击Enter访问登录界面并提供密码以访问桌面。

通过VNC客户端访问RHEL 8桌面

在本文中,我们展示了如何在RHEL 8上安装和配置VNC服务器。像往常一样,您可以通过下面的反馈表单提问。

Guess you like

Origin www.linuxidc.com/Linux/2019-07/159415.htm