Click here to Skip to main content
13,146,742 members (79,713 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

3.8K views
6 bookmarked
Posted 11 Dec 2016
MIT

VNC Experiences on Raspberry Pi

, 11 Dec 2016
Rate this:
Please Sign up or sign in to vote.
VNC experiences on Raspberry Pi

I wanted to share some experiences of getting VNC setup on my Raspberry Pi.

How hard could the experience be? A basic search on Google and there are a ton of tutorials and examples to follow getting everything setup. Being a fan of adafruit, I followed a detailed tutorial they had for setting up VNC which can be found here.

Initially, it was working great till I noticed that I wasn’t accessing the current session. For most configurations, I suspect this works fine but for my current project, I want my VNC session to use the active session that I would see if I had a KVM (keyboard, video, mouse) plugged into my Pi.

Certainly, I am not the first to notice or expect this. After trying different configurations and researching things further, I discovered that the VNC tool used in all of the tutorials (tightvnc) doesn’t support access to the current session. Apparently, in order to achieve this, I would have to install and run X11VNC.

Following are the steps that I took to get everything setup.

Install X11VNC

Open a terminal session on your Raspberry Pi and run the following:

sudo apt-get update
sudo apt-get install X11VNC

When installing X11VNC, it will want you to confirm the install so make sure to answer Yes to these questions. After it’s done installing, you could run x11vnc, but you’ll probably want it to work automatically after restarting your Pi.

Setting Up X11VNC

In your terminal session, you will want to setup a password that can be used when connecting. To set this up, you will want to do the following:

x11vnc --storepasswd

When you are done, x11vnc should report back that the password was written at /home/pi/.vnc/passwd. For some assurances, I checked the file because I didn’t like the idea of password being stored in plain text.

Next, you’ll want to set everything up so that x11vnc is running whenever your pi is started. In your terminal session, change to the config directory.

cd /home/pi/.config

There should already be an autostart directory but go ahead and run a list to see everything that exists in the directory.

ls

If you do not have an autostart directory, then you will need to create one by using mkdir.

Go ahead and change to the autostart directory.

cd autostart

Next, you’ll want to create an entry for x11vnc.

nano X11VNC.desktop

Add the following changes to the file:

[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=X11VNC
Exec=x11vnc -forever -usepw -httpport 5900
StartupNotify=false
Terminal=false
Hidden=false

To close, hit Ctrl-X to keep the changes and exit. Next, you will want to restart your Pi.

Testing X11VNC

Your configuration might be different than mine, however I am running OS X and I can use the built in VNC viewer from Finder. By clicking on the desktop or if you already have a Finder window open, you can do a Cmd-K to connect to a VNC Server.

You will want to enter the address of your Pi using the following format:

vnc://<IP Address>:<Port Number>

If you need to get the IP address of your Pi, you can run ifconfig from a terminal session on it. Once you have entered the Server Address, click on Connect and you should be prompted to enter the password that you supplied.

You should now be connected.

Enjoy and as always, happy coding!!!

License

This article, along with any associated source code and files, is licensed under The MIT License

Share

About the Author

Dennis E White
Software Developer
United States United States
I am software developer with over 20 years of professional experience. I have been employed as a software developer since the early 90′s back when Microsoft’s Windows 3.1x was gaining popularity and IBM’s OS/2 was the predominant leader in 32-bit PC based Operating Systems.

Prior to choosing this as my profession I had studied architecture and then later Electrical and Mechanical engineering in college. As a young kid growing up I always played with computers, my first computer was a TRS-80 that I would spend countless hours writing programs for, I never really thought of programming as a profession. The story goes that in my final year of college I took a C/C++ programming class and had so much fun working on the various projects that my professor told me something that changed everything.

“You know they pay people to do stuff like this for a living?” – Professor Bolman

Check out my blog here.

My current and ever evolving projects:

jqAlert javascript alerts done right for those using jQueryUI.
DooScrib Doodle and scribble pad written in javascript for use with HTML5 Canvas.

You may also be interested in...

Pro

Comments and Discussions

 
QuestionMy vote : 4/5 Pin
ChristianFayet12-Dec-16 21:18
memberChristianFayet12-Dec-16 21:18 
AnswerRe: My vote : 4/5 Pin
Dennis E White13-Dec-16 11:10
professionalDennis E White13-Dec-16 11:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170915.1 | Last Updated 11 Dec 2016
Article Copyright 2016 by Dennis E White
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid