The VNC software is also compatible with the Windows operating system, making communication with the Linux server more efficient and straightforward for Windows users.
Steps to install and configure VNC
Prerequisites
- To begin, purchase a Linux VPS running distributions such as RHEL or Debian, like Ubuntu, for VNC server configuration.
- Ensure you have non-root user privileges and configure a robust firewall, preferably UFW.
- Your local system should run a VNC client compatible with SSH tunnel connections.
Step 1: Installing the desktop environment
Suppose you've installed a minimal operating system version with only a command line interface and no GUI. In that case, the initial step for setting up VNC is to install GNOME, XFCE GUI, or another graphical option to enable seamless interaction with the remote VNC server. Start by connecting to your server via an SSH tunnel and updating your Linux system packages.
sudo apt update
Next, execute the following command to install the GNOME desktop environment, known for its compatibility with RHEL-based distributions:
$ sudo dnf groupinstall "Server with GUI" [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux]
To enhance compatibility with Debian-based distributions and achieve a fast and stable connection using TightVNC software, install the XFCE GUI. Execute the following command to install XFCE on Debian-based distributions, ensuring the inclusion of xfce4-goodies packages for additional advanced features in your desktop environment:
$ sudo apt install xfce4 xfce4-goodies [On Debian, Ubuntu, and Mint]
Step 2: Installing the TightVNC server
Once you've successfully installed the desktop environment, install the TightVNC software, which facilitates remote desktop management and control. Utilize the yum command for the installation process.
$ sudo yum -y install tigervnc-server xorg-x11-fonts-Type1 [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux]
Step 3: Creating a normal VNC user
Create a standard user account with a designated username & password to establish communication with the remote desktop.
$ sudo useradd Opera
Or
$ sudo adduser Opera
$ sudo passwd Opera
Step 4: Setup VNC password
After that, set the VNC password for the user.
Note: The password set in the previous step is for accessing the SSH session, whereas the password defined in this step is for connecting to the remote VNC server desktop. Additionally, please be aware that the password must be between 6 and 8 characters, and setting more than 8 characters is not allowed.
Step 5: Configuring the VNC server
The VNC server needs to be configured to connect to the GUI at startup.
In this tutorial, we will utilize the ~/.vnc/config file within the user configuration settings to configure TigerVNC & connect to the GNOME GUI.
$ vim ~/.vnc/config
The session option has been included to specify the desired session for connection, and the geometry option provides the VNC desktop resolution.
After implementing the changes, log out of the user login using the following command and log in again as the Root user.
$exit
Fortunately, users in TigerVNC can associate a user with a specific port in the /etc/tigervnc/vncserver.users file due to its default configuration settings:
# vim /etc/tigervnc/vncserver.users
Step 6: Starting the TigerVNC server
# systemctl start vncserver@:1 --now
# systemctl enable vncserver@:1 –now
Employ the following command to check whether the VNC service is running:
# systemctl status vncserver@:1
Step 7: Setting Up the VNC port on the firewall
For Opera users, opening port 5901 in your system's firewall (ufw) and iptables is essential.
# iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 5901 -j ACCEPT
Step 8: Connecting to the VNC desktop
After installing VNC Viewer, launch the application. You'll be prompted to enter the IP of the VNC server and the VNC ID for the desired user (e.g., Opera user with ID:1). Finally, input the password set with the "vncpasswd" command.
Connecting to the VNC desktop via the SSH tunnel
For secure VNC connections, it's advisable to create an SSH tunnel. To do this on Linux, use the following command for SSH tunnelling:
ssh -L 59000:localhost:5901 -C -N -l username your_server_ip
Leave a comment: