While windows comes with Remote Desktop built in (for servers and business level editions), Linux operating system do not have a remote desktop system immediately available. Fortunately this is simply a product of there being multiple different remote desktop type tools available.
In this post I am going to show you how to setup my personal favourite Linux Remote Desktop tool called 'TightVNC' on Slackware Linux. (VNC = Virtual Network Computing) TightVNC is an open source tool which consists of a vncserver and a vncviewer/client. TightVNC has both a linux and windows edition.
The first step in setting up TightVNC is to install the package in Slackware. This is made simple as Slackware now comes with a TightVNC. However it is not installed by default, instead you can find it in the extras directory of the install cd/dvd. Alternatively you can download it from the slackware website. Simply navigate to your version of slackware -> extras -> tightvnc and download the txz file.
Installing tightvnc is now a simple matter of navigating to the directory where you downloaded the txz file and running the pkgtool
cd /[path to tightvnc install package]/
pkgtool
//select current
//select yes to install tightvnc[version].txz
To test if the server is working we first start the vncserver on the machine we want to connect to using the following command. Broken down the command translates as, start vncserver and name this instance '1'.
vncserver :1
Once the server is running we then start the vncclient on the client machine. I used the windows client, but if you are connecting from another linux machine use can start the vnc client using the following command.
vncviewer [ipaddress of the remote machine]:1
While the above command to start the vncserver is all you need to start it, you can supply additional arguments to configure the service. For example the following code tell the server to run with a screeen resolution of 1024x768, allow multiple users to view/control simultaneously and have a dpi of 96 on the virtual server.
vncserver -geometry 1024x768 -alwaysshared -dpi 96 :1
A complete list of the tightvnc options can be found here.
Now that we have the vnc server running we should make it secure. To do this we tunnel the vnc traffic through ssh. This is important as it prevents the username and password from being captured by a third party when you first go to login to the vnc server.
Before I go on here is a quick note on VNC ports. Every vncserver instance that is created has a corresponding port number which is calculated as 5900 + the service instance. Thus the ':1' server has a port number of 5901.
This is important as you will need to know the port number when creating the ssh tunnel.
The first step in configuring or vnc server to tunnel its traffic over ssh is to limit the vncserver itself to only accept traffic from localhost. To do this we add the 'localhost' argument to the vncserver start command. As we will be tunneling our traffic over ssh to the machine our vnc connection will appear as a local connection to the vnc server.
vncserver -geometry 1024x768 -alwaysshared -localhost -dpi 96 :1
As the server now only accepts connections from localhost, connecting to the vnc server now consists of two steps. The first step is to connect to the actual server using SSH.
If you are using linux or have a CLI SSH service installed use the following command. Remembering that 5901 is the port number for the vncserver instance '1'. 8900 refers to the port number we assign on our local computer to accept the traffic from our vncviewer.
ssh IP_OF_TARGET_MACHINE -L 8900/localhost/5901
Now we start the vncviewer on the local computer but instead of supplying this ip:vncinstance_number we supply the localhost:8900 value.
vncviewer localhost:8900
An alternative method which I use is to use the Putty SSH client to setup the tunnel. Start putty and create a new session for your server.
Once you have created the new session open the 'tunnels' option and enter the source port of 5901, where 5901 refers to the port number for the vncserver instance '1'. Then enter the destination as 'localhost:5901'. Add this to the forwarded ports, save the session and open the connection.
Now that we have established the ssh connection the last step is to open the vncviewer. This time we supply the following target 'localhost:1'
Finally we must first tell the vncserver to start kde. To do this we edit the vnc startup file 'xstartup' to read as follows. Note the file is located at '~/.vnc/xstartup'. This file is created when you first run the service.
#!/bin/sh
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
startx &
Edit "/etc/X11/xorg.conf"
Section "extensions"
Option "composite" off
Endsection
For more information on xstartup and tightvnc in general goto https://wiki.archlinux.org/index.php/Tightvnc