Here’s a step-by-step guide on how to install a VNC server on a Linux VM and start a remote GUI session from a Windows desktop:
-
SSH into your Linux VM
Open your terminal and SSH into your VM using the following command:
ssh username@your_server_ip
Replace
username
with your actual username andyour_server_ip
with the IP address of your server. -
Update Your Server
Before you install anything, it’s a good idea to update your server’s package lists:
sudo apt-get update
-
Install the VNC Server
Install the VNC server using the following command:
sudo apt-get install tightvncserver
This will install TightVNC, a free remote control software package.
-
Start the VNC Server
Start the VNC server using the following command:
vncserver :1 -geometry 1920x1080 -depth 24
This will start a VNC server session with a display number of 1 and a resolution of 1920×1080 pixels.
-
Set a VNC Password
The first time you start the VNC server, you will be prompted to set a password. This password will be used to connect to the VNC server from your VNC client.
-
Install a Desktop Environment
If your server doesn’t already have a desktop environment installed, you will need to install one. For example, to install the XFCE desktop environment, you can use the following command:
sudo apt-get install xfce4 xfce4-goodies
Once the desktop environment is installed, you will need to configure your VNC server to use it. Open the
~/.vnc/xstartup
file in a text editor:nano ~/.vnc/xstartup
And add the following lines to the file:
#!/bin/bash xrdb $HOME/.Xresources startxfce4 &
Save and close the file. Then make it executable with the following command:
sudo chmod +x ~/.vnc/xstartup
-
Restart the VNC Server
Finally, restart your VNC server with the following command:
vncserver :1 -geometry 1920x1080 -depth 24
Now, on your Windows machine:
-
Install a VNC Client
There are many VNC clients available for Windows, but one of the most popular is RealVNC’s VNC Viewer, which is free for personal use. You can download it from the RealVNC website.
-
Connect to the VNC Server
Open VNC Viewer and enter the following in the “VNC Server” field:
your_server_ip:1
Replace
your_server_ip
with the IP address of your server. The:1
corresponds to the display number of the VNC server session you started earlier.Click “Connect”. You will be prompted to enter the password you set when you started the VNC server. After entering the password, you should be connected to your Linux VM and see the desktop environment you installed.
Remember, when you’re done with your VNC session, you should stop the VNC server on your Linux VM with the following command:
vncserver -kill :1
This will stop the VNC server session with a display number of 1.
Leave a Reply