How to install and configure VNC server on AlmaLinux, CentOS, RHEL and Fedora Linux

by time news

2023-10-20 12:28:50

In this guide, we will explain how to install and configure VNC Remote Access in AlmaLinux y RHEL 9/8/7 desktop edition through the program Tigervnc-server to access remote desktop machines.

VNC ( Virtual Network Computing ) is a server-client protocol that allows user accounts to remotely connect to and control a distant system by using resources provided by the graphical user interface.

Unlike other servers VNC available that connect directly to the running desktop, such as VNC X o Vino , Tigervnc-vncserver uses a different mechanism that sets up a separate virtual desktop for each user.

Step 1: Install and configure VNC

1. Tigervnc-server It is a program that runs a server Xvnc and starts parallel sessions of Gnome or other desktop environments on the VNC desktop.

The same user can access a user session of the VNC launched from multiple VNC clients. To install the server TigerVNC one CentOS/RHEL open a terminal session and run the following yum command with root privileges.

$ sudo yum install tigervnc-server

Install TigerVNC on Linux

2. After installing the program, log in as the user you want to run the program VNC and run the following command in terminal to set a password for the VNC server.

Please note that the password must be at least six characters.

$ are – your user
$vnc password

Create VNC password

3. Next, add a service configuration file VNC for your user via a daemon configuration file located in the directory tree systemd. To copy the template file VNC you need to run the following cp command with root privileges.

If your user is not granted sudo privileges, switch directly to the root account or run the command from an account with root privileges.

# cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service

4. In the next step, edit the VNC template configuration file copied from the directory /etc/systemd/system/ and replace the following values ​​to reflect your user as shown in the following example.

The value of the sign 1 after @ represents the display number (port 5900+display). Additionally, for each VNC server started, the port 5900 will increase by 1 .

# vi /etc/systemd/system/vncserver@:1.service

Add the following lines to the file vncserver@:1.service .

[Unit]

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

[Service]

Type=forking
User=linuxparty
Group=linuxparty
WorkingDirectory=/home/linuxparty
ExecStartPre=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :’
ExecStart=/usr/bin/vncserver %i -geometry 1280×1024
PIDFile=/home/linuxparty/.vnc/%H%i.pid
ExecStop=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :’

[Install]

WantedBy=multi-user.target

Configure the VNC system

5. After you have made the appropriate changes to the VNC service file, reload the systemd system boot program to select the new vnc configuration file and start the server TigerVNC .

Also, check the service status VNC and enable the VNC daemon system-wide by issuing the following commands.

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

Start VNC service

6. To list open ports in the listening state owned by the VNC server, run the ss command, which is used to list network sockets. Because you have only started one VNC server instance, the first open port is 5901/TCP .

Again, the ss command must be run with root privileges. In case you start other VNC instances in parallel for different users, the port value will be 5902 for the second, 5903 for the third, and so on. The ports 6000+ They are used to allow X applications to connect to the VNC server.

#ss-tulpn| grepvnc

Check VNC listening ports

7. To allow external VNC clients to connect to the VNC server, you must ensure that the appropriate open VNC ports can pass through your firewall.

In case only one VNC server instance is started, you only need to open the first assigned VNC port: 5901/TCP by issuing the following commands to apply the firewall configuration at runtime.

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

Step 2: Connect to CentOS Desktop via VNC Client

8. Being a platform-independent protocol, connections VNC graphical user interface Remote access can be done from almost any operating system with a GUI and a specialized VNC client.

A popular VNC client used in operating systems Microsoft based, fully server compatible Linux TigerVNC es RealVNC VNC Viewer .

To connect remotely to CentOS Desktop from a Microsoft operating system via the VNC protocol, open the program VNC Viewer add the IP address and port number of the CentOS VNC server and press the key [enter] .

Once the VNC connection is established, a warning should appear on your screen stating that the connection is not encrypted, as illustrated in the following screenshots.

VNC viewer client

VNC Viewer Client Connection

9. To ignore the warning, press the button Continue add the password settings for the VNC server in point 2 and you should be remotely connected to CentOS Desktop with the user configured to run the VNC server instance.

VNC Server User Password

VNC Remote CentOS Desktop

10. In case a new message appears Authentication on your screen and your user does not have root privileges, just press the button Cancel to continue with CentOS Desktop, as shown in the following screenshot.

VNC Server Authentication Warning

Please note that the VNC communication established between the server and the client and any data exchanged (except the password) is executed over an unencrypted channel. To encrypt and secure VPN data transfer, you must first configure a secure SSH tunnel and run any subsequent VPN traffic through the SSH tunnel.

11. To remotely connect to CentOS Desktop via the VNC protocol from other CentOS desktops, first ensure that the package vinegar is installed on your system by issuing the following command.

$ sudo yum install vinegar

12. To open the utility vinegar go to Applications -> Utilities -> Remote Desktop Viewer as shown in the following screenshot.

Open Vinegar Tool

13. To remotely connect to a CentOS desktop, press the button To connect select the protocol VNC from the list and add the IP adress and the port ( 5900+ screen number) of the remote VNC server. Also, provide the password settings for the VNC user as illustrated in the following screenshots.

Select Remote Desktop Protocol

Enter remote VNC details

VNC CentOS Remote Desktop

14. Another popular VNC client for Linux-based platforms is Remmina, a remote desktop client used especially in Debian-based distributions running the GNOME desktop environment.

To install the client Remmina Remote Desktop On Debian-based distributions, run the following command.

$ sudo apt-get install remmina

Step 3: Set up multiple VNC sessions on CentOS

15. In case you need to run a new parallel VNC session with the same user, open a Terminal console, log in with the user you want to start the new VNC session with, and run the following command.

When you start the server for the first time, you will be asked to provide a new password for this session. However, note that this session runs with the permissions of the logged-in user and independently of the logged-in systemd VNC server session.

$vnc server

Start new VNC session

16. New VNC sessions will open the following available VNC-based ports (screen 5900+3 in this example). To display open ports, run the ss command without root privileges as illustrated in the following excerpt. It will list only the started VNC sessions that your user should.

$ss-telpn| grepXvnc

List open VNC ports

17. Now, remotely connect to CentOS Desktop using this new VNC session and provide the IP:port combination (192.168.1.23:5903) in the VNC client as illustrated in the following image.

Connect to VNC Remote Desktop

To stop VNC server instances started with these registered user permissions, issue the following command without any root privileges. This command will destroy all started VNC instances that belong only to the user who pointed them.

$ are – your user
$killall Xvnc

That’s all! You can now access your system and perform administrative tasks using the graphical user interface provided by the operating system.

#install #configure #VNC #server #AlmaLinux #CentOS #RHEL #Fedora #Linux

You may also like

Leave a Comment