In today’s digital age, remote access to desktops has become an essential need for many individuals and organizations. Virtual Network Computing (VNC) is a popular desktop sharing protocol that allows users to remotely control a computer using VNC client software. Whether you’re a technician providing support or someone who needs to access their office desktop from home, installing a VNC Server on your AlmaLinux 9 server can streamline your workflow and enhance productivity.
In this comprehensive guide, we will walk you through the step-by-step process of installing and configuring a VNC Server on your AlmaLinux 9 server. We will be using TigerVNC Server and XFCE as the default desktop environment. So let’s dive in and get started!
Prerequisites
Before we begin, let’s ensure that we have everything we need to successfully install the VNC Server on AlmaLinux 9:
- An AlmaLinux 9 server: For this guide, we will be using an AlmaLinux 9 server with the hostname
alma9
and the IP address192.168.10.20
. - A non-root user with administrator privileges: Make sure you have a non-root user with sudo privileges to perform the installation and configuration steps.
Installing the Desktop Environment
The first step in setting up the VNC Server is to choose the desktop environment you want to use. Linux offers a variety of desktop environments, each with its own strengths and weaknesses. For our setup, we will be using XFCE as it is lightweight and suitable for servers with limited resources.
To install XFCE, we need to add the EPEL repository to our system. Open your terminal and run the following command:
sudo dnf install epel-release
When prompted, enter y
to confirm the installation. Once the installation is complete, run the following command to install XFCE and its dependencies:
sudo dnf groupinstall"Xfce" "base-x"
Again, confirm the installation by entering y
. If prompted to confirm the GPG key for the EPEL repository, enter y
and press ENTER
to proceed.
Once the installation is finished, we need to set the default startup to use the graphical environment. Run the following command:
sudo systemctl set-default graphical
If you prefer to use a different desktop environment, such as Gnome or KDE, you can use the respective commands to install them:
Install Gnome Desktop Environment:
sudo dnf groupinstall "Server with GUI"
Install KDE Desktop Environment:
sudo dnf groupinstall "KDE Plasma Workspaces"
Installing and Configuring TigerVNC Server
With the desktop environment installed, we can now proceed to install the TigerVNC Server, which will allow us to create and configure our VNC Server.
Adding a New User
Before we install the TigerVNC Server, let’s create a new user that will be used to run the VNC Server. This user will also need sudo privileges. Run the following commands to create a new user named shapehost
and set up sudo privileges for them:
sudo useradd -m -s /bin/bash shapehost sudo passwd shape.host
Enter a password for the new user when prompted. Next, add the user to the wheel
group, which allows them to run the sudo command:
sudo usermod -aG wheel shapehost
Installing TigerVNC Server
With the new user created, we can now install the TigerVNC Server package. AlmaLinux 9 includes the package in its default appstream repository, so we can install it using the DNF package manager. Run the following command to install TigerVNC Server:
sudo dnf install tigervnc-server
Confirm the installation by entering y
when prompted.
Configuring VNC Server with TigerVNC Server
Now that we have installed the TigerVNC Server, let’s proceed with the configuration.
- Switch to the
shapehost
user:
su - shapehost
- Create the necessary directories and configuration file:
mkdir -p ~/.vnc/ nano ~/.vnc/config
- In the nano editor, enter the following configuration:
session=xfce securitytypes=vncauth,tlsvnc geometry=1920x1200 localhostalwaysshared
This configuration specifies that we will be using XFCE as the desktop environment, enables VNC authentication and TLS encryption, sets the screen resolution to 1920×1200, and allows shared access from localhost.
- Save and close the file by pressing
CTRL + X
, thenY
, and finallyENTER
. - Set up a password for the VNC Server:
vncpasswd
Enter and confirm the desired password when prompted. You can optionally set up a view-only password, but for simplicity, we won’t be configuring it in this guide.
- Set the SELinux context for the
~/.vnc
directory:
restorecon -RFv ~/.vnc
- Open the
/etc/tigervnc/vncserver.users
file for editing:
sudo nano /etc/tigervnc/vncserver.users
- Add the following line to the file to create the VNC Server for display
:1
for the usershapehost
:
:1=shapehost
- Save and close the file.
- Reload the systemd manager:
sudo systemctl daemon-reload
- Start and enable the VNC Server:
sudo systemctl start vncserver@:1 sudo systemctl enable vncserver@:1
- Verify the status of the VNC Server:
sudo systemctl status vncserver@:1
If everything was successful, you should see the VNC Server display :1
with an active (running) status.
Configuring Firewalld
To ensure that our VNC Server is accessible, we need to open the necessary port in the firewall. By default, AlmaLinux 9 uses firewalld as its firewall management tool. Let’s open the VNC Server port by following these steps:
- Start the firewalld service if it’s not already running:
sudo systemctl start firewalld
- Add the VNC Server service to firewalld and reload the firewall rules:
sudo firewall-cmd --add-service=vnc-server --permanent sudo firewall-cmd --reload
- Verify the list of enabled services on firewalld:
sudo firewall-cmd --list-all
You should see the vnc-server
service added to the list.
Accessing VNC Server via SSH Tunneling
To enhance the security of our VNC Server, we can access it securely via SSH tunneling. This allows us to encrypt the VNC traffic and ensure that our connection is protected. Follow these steps to connect to the VNC Server securely:
- Ensure that you have an SSH client software installed on your local machine. For Windows, you can use UltraVNC, and for Linux or macOS, you can use RealVNC or any other compatible client.
- Open a terminal or command prompt on your local machine and run the following SSH command to create an SSH tunnel to the VNC Server:
ssh -L 5901:127.0.0.1:5901 -N -f -l shape.host 192.168.10.20
Replace shapehost
with your username and 192.168.10.20
with the IP address of your VNC Server.
- When prompted, enter the password for the
shapehost
user. - Open the VNC client application on your local machine and connect to
127.0.0.1
with port5901
. Since we have created an SSH tunnel, we can access the VNC Server securely vialocalhost
. - If you receive a warning about unencrypted connections, click on “Continue” to proceed.
- Enter the VNC Server password when prompted and click “OK” to confirm.
If the password is correct, you should now be connected to your VNC Server and see the XFCE desktop environment.
Conclusion
Congratulations! You have successfully installed and configured a VNC Server with TigerVNC Server and XFCE Desktop on your AlmaLinux 9 server. You have also learned how to access the VNC Server securely using SSH tunneling. With your VNC Server up and running, you can now enjoy remote access to your desktop environment and streamline your workflow.
Remember to always prioritize security by using strong passwords and keeping your system up to date. If you encounter any issues during the installation or configuration process, refer to the official documentation or seek assistance from the AlmaLinux community.
If you’re looking for reliable Linux SSD VPS hosting services, consider Shape.Host. They offer high-performance virtual private servers with excellent customer support. Visit their website at shape.host to explore their hosting options and get started with your VNC Server today!