Configure VNC Remote Desktop

Overview

This tutorial describes how to setup a VNC remote desktop server. Following the steps in this tutorial, you will be able to access your Linux desktops from other machines, including your iPad or smartphone. With a VNC remote desktop server you can:

  • Run Linux server machines without a monitor (headless), but still have a graphical UI to administer them with.

  • Control your computer from your iPad.

  • Control your desktop from anywhere you are connected to the internet.

This tutorial is intended for people with minimal knowledge of Linux and the internet.  You should know how to start the linux terminal on your server machines. The instructions in this tutorial will cover all of the commands you must use and the files you must edit to get your remote desktop setup running.

In this tutorial, you will learn:

  • How to install tightVnc server on a Linux machine.

  • How to start a remote desktop server on different ports

  • How to connect to the desktop with a remote desktop client.

  • How to use an SSH tunnel for a secure connection over the internet

VNC Server Side

There are several different VNC server applications available. This tutorial describes how to use tightVNC.

  1. Install the Tight VNC server and its dependancies.

$ sudo apt-get install tightvncserver
  1. Run Tight VNC for the first time to configure the passwords. Enter the control password and an optional view only password at the prompt.

$ tightvncserver
  1. You can start a virtual desktop from a terminal prompt. Do not execute this as a super user, or else you will get the root’s desktop.

$ vncserver :5 -geometry  1080x720 -depth 24

Note, the number after the : designates what port this VNC server is on.  The server will be on port 5900 plus this number (5905 in this example).  You can use different VNC ports if you have multiple servers behind the same router firewall.

Connect to a Remote Desktop

VNC Viewer Client

Using a Mac

There is a VNC viewer client built into Mac.  Open up the Finder, and hit Ctrl K.  In the Server Address field, enter “vnc://address.of.the.computer:portNumber”


You will be prompted to enter the VNC password on your first connection, but you can save this in your keychain for automatic connection in the future.

Using Windows

If you are using Windows, you should download the VNC client viewer application from http://www.tightvnc.com/download.php.

There are also a number of remote desktop applications for the iPad and Android.

With A Web Browser

The VNC server will open a port at 5900 + :display number.  It also opens a port at 5800 + :display number.  You can connect to the VNC server with any capable browser by typing in “http://addressOfServer.net:5805” (or 58xx whatever the display number is).

You must have Java installed for the viewer web application to work. You will also be warned that it is not safe.  After you enter the VNC password, you will see and be able to control the desktop in a browser window:

chromeVNC

Google chrome browser as a VNC viewer on port 5805.

SSH Tunnel into VNC

If you are just using VNC on your secure home LAN, then you are OK to use the VNC viewer client directly. However, VNC is not the most secure, so  if you wish to use remote desktop over the internet, you should use a SSH tunnel into your VNC server.

Using a Mac

  1. Open a terminal, enter:

$ ssh -L 5905:localhost:5905 yourUserName@yourDomainName.net -p1022

 

This command sets up a tunnel from port 5905 on the host machine to port 5905 on the local host.

  1. Now to connect to the remote desktop, in the Server address, enter:

Using Windows

The Windows terminal program Putty supports SSH tunneling.  The process is well described on this web page.

References and Additional Reading