In today’s digital landscape, remote access and control of computers have become essential for businesses and individuals alike. Whether you need to provide technical support or access your office desktop from home, a reliable and secure desktop-sharing protocol is crucial. One such protocol is Virtual Network Computing (VNC), which allows you to control a computer remotely using VNC client software. In this comprehensive guide, we will walk you through the step-by-step process of setting up and installing VNC Server on your Debian 12 server.
Prerequisites
Before we dive into the installation process, there are a few prerequisites that you need to have in place:
- A Debian 12 server: Ensure that you have a Debian 12 server up and running.
- Non-root user with administrator privileges: It is recommended to have a non-root user with administrative privileges to carry out the installation and configuration.
Installing the Desktop Environment
The first step in setting up VNC Server on your Debian 12 server is to install a desktop environment. This will provide a graphical user interface (GUI) for your VNC Server. There are various desktop environments available, and you can choose the one that suits your needs. We will use the XFCE desktop environment for this guide.
To install the XFCE desktop environment, follow these steps:
- Update your Debian repository by running the following command:
sudo apt update
- Install the “tasksel” package, which is a command-line tool that helps you install groups of packages such as desktop environments. Use the following command to install “tasksel”:
sudo apt install tasksel
- After installing “tasksel”, execute the following command to install the XFCE desktop environment:
sudo tasksel
- This will open an interactive shell where you can select the desktop environment you want to install. Use the arrow keys to navigate and press the space bar to select XFCE. Once selected, press ENTER to start the installation.
The installation process may take some time, depending on your internet connection speed. Once the installation is complete, you will have the XFCE desktop environment installed on your Debian 12 server.
Installing TigerVNC Server
With the desktop environment installed, we can now proceed to install the TigerVNC server package, which will enable us to create a VNC Server on our Debian 12 server.
To install TigerVNC server, follow these steps:
- Run the following command to install the TigerVNC server packages:
sudo apt install tigervnc-standalone-server tigervnc-common
- When prompted, enter ‘y’ to confirm the installation.
After the installation is complete, you will have the necessary packages to set up your VNC Server.
Initializing the VNC Server
Now that TigerVNC server is installed, we can initialize our VNC Server by setting a password and configuring the view-only password (if desired).
To initialize the VNC Server, follow these steps:
- Log in to your non-root user by running the following command:
su - shapehost
- Initialize the VNC Server by running the following command:
vncserver
- You will be prompted to set a new password for the VNC Server. Enter your desired password and confirm it when prompted.
- Next, you will be asked if you want to set a view-only password. This password is optional and allows users to view your desktop without having control. Choose ‘n’ to disable the view-only password or ‘y’ to enable it.
Once the initialization process is complete, your VNC Server should be up and running on your Debian 12 server.
Configuring the VNC Server and Desktop Environment
After initializing the VNC Server, we need to configure it to use the XFCE desktop environment as the default session.
To configure the VNC Server and desktop environment, follow these steps:
- Stop the current VNC Server process by running the following command:
vncserver -kill :1
- Run the following command to check the available desktop environments on your system:
ls /usr/share/xsessions/
- This will display a list of available desktop environment configurations. Look for the configuration file ending with ‘.desktop’ for the XFCE desktop environment.
- Create a new VNC Server configuration file by running the following command:
nano ~/.vnc/config
- In the nano editor, enter the following configuration settings:
session=xfce geometry=1200x720 localhostalwaysshared
- Save and close the file.
By configuring the VNC Server with the XFCE desktop environment, we ensure that the XFCE session will be the default when connecting to the VNC Server.
Adding Users to the VNC Server
To allow users to connect to the VNC Server, we need to add them to the VNC server configuration file.
To add users to the VNC Server, follow these steps:
- Open the VNC server configuration file using the following command:
sudo nano /etc/tigervnc/vncserver.users
- Add the following line to the file, replacing ‘username’ with the desired username:
:1=username
- Save and close the file.
Starting and Enabling the VNC Server Service
With the users added to the VNC server configuration, we can now start and enable the VNC Server service to ensure it runs automatically on boot.
To start and enable the VNC Server service, follow these steps:
- Start the VNC Server service by running the following command:
sudo systemctl start tigervncserver@:1.service
- Enable the VNC Server service to start automatically on boot:
sudo systemctl enable tigervncserver@:1.service
- Verify that the VNC Server service is running by running the following command:
sudo systemctl status tigervncserver@:1.service
Connecting to the VNC Server via SSH Tunneling
To connect to the VNC Server securely, we will use SSH tunneling, which encrypts the VNC traffic and ensures a secure connection.
To connect to the VNC Server via SSH tunneling, follow these steps:
- Ensure that you have an SSH client and VNC Viewer installed on your local machine. For Windows users, you can use PowerShell with an SSH client installed, along with UltraVNC for the VNC client. For Linux users, you can use the terminal and Remmina remote desktop application.
- Open your terminal or PowerShell and run the following command to create an SSH tunnel to the VNC Server:
ssh -L 5901:127.0.0.1:5901 -N -f -l shapehost shape.host
- Replace ‘shape.host’ with the IP address or hostname of your Debian 12 server.
- Open the VNC Viewer application and connect to ‘localhost’ or ‘127.0.0.1’ with port 5901.
- Enter the VNC Server password when prompted and click ‘Log On’.
If the password is correct, you should now be connected to the VNC Server and have access to the XFCE desktop environment.
Installing Graphical Applications to the VNC Server
With the VNC Server connection established, you can install additional graphical applications to enhance your remote desktop experience.
To install graphical applications on the VNC Server, follow these steps:
- Click on the ‘Applications’ menu in the XFCE desktop environment and select ‘Terminal Emulator’.
- In the terminal, run the following command to update the Debian package repository:
sudo apt update
- Once the repository is updated, you can install any desired graphical application using the ‘apt’ command. For example, to install Firefox ESR, run the following command:
sudo apt install firefox-esr -y
- After the installation is complete, you can open the installed application from the application menu and start using it within your VNC Server session.
Conclusion
Congratulations! You have successfully set up and installed VNC Server on your Debian 12 server using TigerVNC and the XFCE desktop environment. You have also learned how to connect to the VNC Server securely via SSH tunneling and install additional graphical applications. With VNC Server, you can now enjoy remote access and control of your Debian server with ease.
For reliable and scalable cloud hosting solutions, including Linux SSD VPS, visit Shape.host. Shape.host provides industry-leading cloud hosting services, ensuring your servers are secure, efficient, and always available.