
Introduction
VNC (Virtual Network Computing) is a straightforward method for sharing a graphical desktop environment. For instance, by installing VNC on your hosted server, you can remotely access its graphical desktop interface.
At Buy Cheap VPS, installing the VNC template is quick and simple, requiring just a few clicks:
- Log into the Client Area.
- From the top menu, select My Services > VPS.
- Click the Manage button on your service table.
- Click the Install OS button.
- Choose your operating system, acknowledge the warning, and click Continue.
- Wait 5-10 minutes, then refresh the VPS management page.
1. Configuring the VNC Server to Listen Only for Localhost Connections
To configure your VNC server to accept connections only from localhost, follow these steps:
Open the VNC configuration file:
For CentOS:
nano /etc/sysconfig/vncservers
For Ubuntu:
nano /etc/vncserver/vncservers.conf
Add the -localhost option at the end of the VNCSERVERARGS line, like this:
VNCSERVERARGS[1]="-geometry 1024x768 -localhost"
Restart the VNC service:
service vncserver restart
2. Connecting to the Server via SSH Tunnel on Linux
To set up an SSH tunnel on a Linux system, run the following command in your console:
ssh -L 5901:localhost:5901 -N -f -l vncuser IP_of_the_server
Explanation of the command:
-L 5901:localhost:5901 : Forwards port 5901 on your local machine to port 5901 on the remote server.
-N : Does not execute a remote command; just forwards the ports.
-f : Sends the SSH session to the background once the password is entered.
-l vncuser : Specifies the username for logging in to the remote machine.
IP_of_the_server : Replace with your server's IP address or hostname.
Once the tunnel is established, you can connect to the server using VNC clients like TigerVNC, TightVNC, etc., at the address localhost:5901.
3. Connecting to the Server via SSH Tunnel Using PuTTY (Windows)
To connect via an SSH tunnel on a Windows machine using PuTTY:
In PuTTY, go to Connection > SSH > Tunnels.
Under Source Port, enter 5901.
Under Destination, enter localhost:5901.

Click Add to set up the tunnel.
Then, connect to your server using its IP address and port 22.

Once connected, use a VNC viewer (like TigerVNC, TightVNC, etc.) to connect to localhost:5901.