Troubleshooting VNC Server Installation on Rocky Linux

Published on

Troubleshooting VNC Server Installation on Rocky Linux

Virtual Network Computing (VNC) allows users to connect to a graphical desktop environment and control it from another location. It can be particularly useful when managing servers without a physical interface. In this blog post, we’ll troubleshoot VNC Server installation on Rocky Linux with a focus on the challenges you might face and the solutions to overcome them.

Table of Contents

  1. Understanding VNC Server
  2. Prerequisites for VNC Installation
  3. Installation Steps
  4. Common Installation Issues and Solutions
  5. Configuring VNC Server
  6. Testing the Connection
  7. Conclusion

Understanding VNC Server

VNC works by sending keyboard and mouse events from one computer to another while sending graphical screen updates back in the opposite direction. A VNC server runs on the remote computer you want to control, and a VNC viewer (client) is installed on the local machine.

Why use VNC?

  1. Remote Access: Manage your server without a physical interface.
  2. Multi-User Support: Multiple users can connect to the same session.
  3. Cross-Platform: VNC works across different operating systems.

Prerequisites for VNC Installation

Before we dive into the installation process, ensure that you meet the following prerequisites:

  1. Access to the Rocky Linux server: SSH access is typically required.
  2. Workspace: Installation must be performed with superuser (root) permissions.
  3. Firewall Configuration: Make sure that ports 5900 (and above) are accessible.

Installation Steps

1. Update Your System

Start by updating your system to ensure that all packages are up to date:

sudo dnf update -y

2. Install TigerVNC Server

Install the TigerVNC server, which is a popular choice:

sudo dnf install tigervnc-server -y

3. Enable the Service

You need to enable and start the VNC server service:

sudo systemctl enable vncserver@:1.service
sudo systemctl start vncserver@:1.service

4. Configure Firewall Rules

Allow access to the VNC port. By default, VNC operates on port 5900 plus the display number, so when starting display :1, you will need to allow port 5901.

sudo firewall-cmd --zone=public --add-port=5901/tcp --permanent
sudo firewall-cmd --reload

Common Installation Issues and Solutions

Issue 1: VNC Service Fails to Start

In some cases, the service may fail to start. To troubleshoot this:

  1. Check logs for any error messages:

    journalctl -xe
    
  2. Make sure that the VNC server is properly installed and configured.

Issue 2: Connection Refused Errors

If a client receives a "Connection refused" error, consider the following checks:

  • Ensure the service is running:
    systemctl status vncserver@:1.service
    
  • Check Firewall Settings: Ensure that the necessary port is open.

Issue 3: Authentication Issues

If using a password prompt fails:

  1. Create a password file:
    vncpasswd
    
  2. Ensure that the password is saved correctly in ~/.vnc.

Configuring VNC Server

Once installed, you need to configure the VNC server to customize the desktop environment.

1. Create a Configuration File

Create or edit the VNC configuration file:

nano ~/.vnc/xstartup

Add the following lines to initialize your desktop environment:

#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
exec /etc/X11/xinit/xinit -- :1 vt7 -nolisten tcp &
exec startxfce4 &

2. Set the Permission

Make sure the xstartup file has the correct permissions:

chmod +x ~/.vnc/xstartup

3. Restart VNC Server

Once configured, restart the VNC server:

sudo systemctl restart vncserver@:1.service

Testing the Connection

With VNC server running, you can now test your connection.

  1. Install a VNC Viewer on your local machine.
  2. Connect using the server's IP address and display number:
    <Server_IP>:1
    
  3. Enter the password you set with vncpasswd.

To Wrap Things Up

VNC provides a powerful way to manage remote systems. However, installation may not always be straightforward. This blog post elucidated the steps to install and configure the VNC Server on Rocky Linux. We also tackled common issues, giving you the tools you need to troubleshoot and resolve them efficiently.

For further reading, you may check out Rocky Linux documentation for in-depth information and VNC documentation for guidance on using VNC.

With these steps, you should have a working VNC Server setup on your Rocky Linux system. Happy remote computing!