- Raspberry Pi: Setting Up VNC On Raspbian Pt1
- Raspberry Pi: Setting Up VNC On Raspbian Pt2
The Raspberry Pi is a great affordable Pc with a lot of power for its size. This is what makes it great for so many projects in so many settings. However, it’s not always easy to find accurate information in full. At Code Clinic we’ve spent many an hour trying to set-up a working VNC server to allow us to run the Pi headerless (eg without a keyboard and mouse attached). We’ve seen and tried so many tutorials, and scoured seemingly endless forums trying to get VNC to work but without success. So now we’ve got a nice reliable set-up running we thought we’d share our knowledge.
Choosing the right VNC Server
There are several software projects that support VNC. But the best one for your needs is highly dependent on what you need to do via the VNC and ultimately with your Pi. If you simply need a connection into the Pi to do general task and run completely headerless we recommend you to use TightVNC because it is free open source software, provides compression to allow it to work over a slow network (Internet) and is readily available in the software repositories.Plus it seems to be the most reliable of the lot.
To install TightVNC we recommend you read Raspberry Pi: Setting Up VNC On Raspbian Pt1.
If you need to work specifically with the same desktop as that being shown on a monitor attached to the Pi, then you’ve probably already discovered that there isn’t much in the way of reliable info available. Luckily, we’ve created this guide for you.
Client server model
VNC follows the traditional client sever model. The server software runs on the Pi to be accessed, and the client software runs on the local machine that wishes to control the host. The server and client do not have to be the same (eg. the client can be RealVNC when the server is x11VNC), but some features may only work when the same client and server are used.
Install the VNC server software
In order to run VNC on the default Desktop -eg: the one you’d see on the monitor attached to the Pi, we’re going to need to use an x11 VNC server.
To do this, we first need to refresh and update the software repository information using:
sudo apt-get update && apt-get upgrade
This will update your repository data and upgrade any software already installed. This is particularly important if you have just installed the operating system as the repository information may be incomplete.
Next we need to install the TightVNC from the repositories:
sudo apt-get install x11vnc x11vnc -storepasswd
You should be prompted to enter a password for the VNC Server once the installation is complete. We strongly recommend you do so, for security purposes.
Autostart the VNC server
Next we need to create the entry that will launch the x11VNC server when the Pi boots into it’s desktop:
cd .config mkdir autostart cd autostart nano x11vnc.desktop
The next step is to paste the following into the nano terminal editor:
[Desktop Entry] Encoding=UTF-8 Type=Application Name=X11VNC Comment= Exec=x11vnc -forever -usepw -display :0 -ultrafilexfer StartupNotify=false Terminal=false Hidden=false
Now save the file and exit nano:
Ctrl-x Y < return >
Now its time to reboot your Pi, and check x11VNC starts up automatically:
Thats all there is to it. For info on how to run a standard VNC on Raspbian Desktop see part 1