
Virtual Network Computing (VNC) is a connection system that allows you to use your local computer, mouse, and keyboard to control a remote server running a graphical desktop environment. VNC makes software installation, file management, and server setup easy since it offers a straightforward point-and-click graphical user interface (GUI).
In this article, you will learn how to install, configure and secure VNC on Debian 11 using Tight VNC.
Depending on your graphical environment flavor, there are several variants like Xfce and KDE, among others to choose from. This tutorial explains how to install the Gnome environment.
Update and upgrade the server packages.
Install necessary Gnome fonts:
Install Gnome:
Similar to Gnome, several VNC variants are available in Debian repositories. For this article, install Tiger VNC because it's secure and actively maintained.
Install Tiger VNC by running the following command:
Configure VNC with an access password for your account, then create the initial configuration files directory by running the following command:
Enter a strong password to keep your server secure. Also, select n when prompted to enter a view-only password since this would limit you from controlling the remote server.
Once configured, Your output will be similar to the one below:
1represents the display port number, and it's incremented on the service port, instead of 5900, it becomes 5901, representing your account port. If you run thevncservercommand again, a new port number will be generated.
A new hidden directory ~/.vnc is automatically created, set up a new xstartup configuration file within the directory to configure Gnome as the default graphical environment.
But first, stop the current VNC instance.
Then, using your favorite editor, create and edit the file ~/.vnc/xstartup.
Paste the following lines of code:
Save and close the file.
Now, grant execute permissions on the configuration file.
Configure the VNC instance to run as a system service to start, stop, or restart it using systemd management tools instead of manually running vncserver in your console.
Create a new service file in the /etc/systemd/system/ directory.
Paste the following lines of code:
Replace example with your actual username, and set your preferred display resolution next to the -geometry entry. Finally, save and close the file.
Restart the Systemd daemon.
Now, enable VNC to start at boot time.
Output:
1represents the port number of your current VNC instance as displayed in the configuration output earlier.
Next, start the VNC Service.
Verify that VNC is up and running by querying the current status.
Your output should be similar to the one below:
By default, VNC traffic is not encrypted, which presents security risks such as packet sniffing. However, you can securely connect to your server over VNC by adding an SSH encryption layer to the connection.
Depending on your local PC operating system, securely connect to your Debian 11 server over VNC using the following procedures.
Open Terminal, and create an SSH tunnel with the following command:
Lspecifies that SSH connections to the server port5901have to be forwarded to the specified host (127.0.0.1), and port.Ccompresses all data.Ninstructs SSH to strictly forward data with no console window commands.
Your VNC connection will be tunneled through SSH and available on localhost port 5901. Use your VNC client software to make a connection to 127.0.0.1:5901, and start using your remote Debian 11 server desktop.
For the best display quality, change your VNC Viewer picture quality settings from Automatic to High.
To securely tunnel your VNC connection on Windows, Install Putty if not already installed, then set up SSH tunneling by navigating to the Session tab.
Establish an SSH connection to the server on port 22, then, in the SSH console window, right-click on the top bar, and select Change Settings from the options list. Under Connection expand the SSH option and select tunnels.
Enter the local source port (5901), then enter your local computer address 127.0.0.1 with VNC remote port 5901, and click Add to save the SSH forwarding information.
Now, click Open to start SSH forwarding to the localhost port. Open your VNC Viewer and enter address 127.0.0.1:5901 to establish a secure connection to the server. Once connected, your Debian 11 Gnome desktop is displayed.
If you receive the following error after running the command vncserver:
Log out of your current user account, then re-login with su – Username.
You have successfully installed, configured, and securely connected to your VNC server on Debian 11. For every user account you create, a new port number will be created. Use the same above process to securely connect to the server.
0 Comments
Be the first to comment and share your perspective with the community.