I have rented a VPS, with Ubuntu. I can access it by console and SSH.
I wanted to install a graphical desktop system on it and use it as remote desktop.
So, here are the steps I follow...
Firstly, we need to install graphical desktop environment like XFCE, KDE, GNOME, LDE.
I will install XFCE.
Let's start...
sudo apt-get install xfce4
If you perefer to install some other desktops use one of the following terms: xfce4, lxde, gdm, kde, ubuntu-desktop, xubuntu-desktop
And now, I need to install VNC server, to connect remotely.
sudo apt-get install tightvncserver
Now, let's configure tightvncserver and set our password by the following command
vncpassword
We can run tightvncserver now
vncserver
Or to specify desktop size use -geometry paremeter
vncserver -geometry 1000x650
This will give us a display number like 1.
Now we can connect to the remote server by the IP and that display number using a VNC Viewer tool like TightVNC Viewer, Ultra VNC Viewer.
And the remote computer ready for use.
That's all!
By the way, we can install multiple related packages in ease by tasksel.
Security for VNC Server
For better security we can start vncserver on VPS to be accessed only from localhost by:
vncserver -localhost
To be able to connect to the vncserver from local computer, we need create SSH tunnel and forward related ports (5901, 5902, etc.)
ssh user@vpsaddress -L 5901:localhost:5901
If you need you can forward multiple ports by using more -L parameters.
For example, the following command runs the tunnel process at background, and forwards multiple ports, and compress transfer data:
ssh -N -f -C -v user@vpsaddress -L 5901:localhost:5901 -L 5902:localhost:5902
Then, we can connect to the remote desktop on VPS using a VNC Viewer like:
vncviewer localhost:5901
Some SSH parameters meanings:
-C: Compress transfer data.
-v: Verbose
-N : Do not execute a remote command i.e. just forward ports.
-f : Requests ssh to go to background just before command execution. After authenticated it will go to background and you can use prompt for type commands on local system.
References: