Pages

Setting Up VNC

While the Raspberry Pi does provide a superb picture over hdmi, there
are a lot of scenarios where one might not need a display, and
connecting remotely via VNC will suffice. For instance, any programming
could be done remotely, while still having access to the physical
hardware. It's also particularly useful when the TV is in use and
getting it back to "play on" isn't an option.

Now, once the VNC server is up and running on the Pi you can VNC from your laptop into your Pi without doing anything on the Pi first. If you've just turned it on however,
you'll need to first start the VNC server on the Pi. And if you're using this as
a truly headless box, that can be a little difficult. To get around
this I've used the PuTTY SSH client, which you can download here:PuTTY Downloads Page

The last thing you need to know is the IP Address. If you've configured
your Pi with a static IP Address, that's great. If you have access to
your router to look this up that's fine too. You might however be in a
situation where you have no way to look up the IP Address (like me) -
for this I needed a utility to scan the network for all machines. For
this I used:Advanced IP Scanner
This will scan your network listing all devices it can find. Simply look through the list of devices and find your Rashberry Pi. It'll have a fairly obvious name, like "RaspberryPi".

Alternatively, if you have access to your wireless router, you might be able to connect to this and see a list of all devices that have connected to it, including your Raspberry Pi. As each wireless router differs, I'll leave this up to you to figure out :-)

Starting SSH on the PiFirst off - what is SSH? It's a process that can be run in Linux that will allow you to access your Raspberry Pi remotely. You'll be able to run anything that you would normally run from the command line on your Raspberry Pi, remotely from an SSH client - i.e. Putty. #

I've
found that the latest Debian image doesn't come with SSH enabled by
default. If you have a monitor and keyboard attached, once you've
logged in you can start SSH by typing sudo /etc/init.d/ssh start as shown below:

Now, the
idea of SSH is that we can connect remotely without a display, so you
don't necessarily want to have to do this every time you boot up.

EDIT 28/01/2013: There are two approaches to enabling SSH.

First option
For older images like Debian there is a file in place that can be used to do this - boot_enable_ssh.rc. This file is on the boot partition of the SD card - i.e. the partition that can be read by Windows. So - put the card into your PC card reader and open it up:

Now rename boot_enable_ssh.rc to boot.rc:

Once you've done this put the card back into the Pi and boot up - SSH will now be automatically enabled.

Second option
If you're using a newer distro like Raspbian Wheezy, when you first boot up the image you'll be taken to a config screen. From here you'll be able to enable SSH (along with a number of other useful options!).

Connecting via SSH
As mentioned above, to be able to connect into the Pi using VNC you
first need to start the VNC server, and without a display connected you
need to start this remotely. SSH provides this mechanism. To start with, we take our SSH Client - PuTTY. Once you've downloaded it, simply launch it - it's a standalone exe - you'll be presented
with this screen:

Simply type in Raspberry Pi IP Address in the Host Name field that you found earlier and click open. Once Putty has connected to the SSH process running on the Pi, a terminal window will pop up and you'll be prompted with a login.

I still have my UN & PW set to pi and raspberry, so just typed that
in. Once logged in I'm taken to the standard terminal prompt. From
here you can run pretty much any command you want on the Raspberry Pi.

Setting up VNC Server via SSH
Now that you're connected, you need to start the VNC server. If this is
the first time you're doing this, you'll also need to install VNC
first. I've assumed you'll have internet access as this will be
required to install this. To do this, run the following command:sudo apt-get install tightvncserver
As mentioned above, the Putty SSH Client lets you run commands on your Pi directly, so by doing this you're installing a VNC application on your Pi.NOTE: during the install you'll be prompted to install without verification - type y here.

This will start the VNC server process on the Pi. What this means is that it will start a virtual X session (a virtual instance of the Raspberry Pi GUI) on your Pi, in a very similar way to when you run startx when your Pi is connected to a display. When you VNC into your Pi you will be connecting to this X session.

So - the important port of this command is :1. This defines the port that the VNC process will be started on - you can make this whatever you want, but will need to remember it to ensure you connect to the right port. You'll see more details on this below. As for the resolution (-geometry) this will be the resolution that the X session will run under - you can make this pretty much whatever you want

The first time you launch VNCServer you'll be prompted for a password - you'll need this to connect in using VNC.

You'll also be asked for a view-only password (optional). When
providing the password via VNC the remote use will only have read-only
access to the Raspberry Pi:

Connecting via UltraVNC Once VNC
server has been started the only thing left to do is connect. Start up
UltraVNC, type in the IP Address (or machine name) with a port of 1 and
connect. NOTE: This port is the port you used when starting the VNC process above:

And that's it - connected!

EDIT 06/05/2012: I've found out there are two potential desktops you might see, and this is determined by the user that launches vncserver (or startx for that matter). Using sudo will give you the LXDE desktop above. Launching it without sudo will give the intended Raspberry Pi desktop as shown below.

Update on my post, it may help newbies like me. After many different test etc, even changing firewalls I logged into the Pi itself, and looked at the filename. There I discovered the renamed file is "boot.rc.rc". Yep, using windows, I changed the name to "boot.rc", and windows must have added the extra ".rc" as per original file. Now all work as should. Thank you for your description of SSH.

There's no need to remove the SD from the Pi to get SSH on startup. Simply 'sudo mv /boot/boot_enable_ssh.rc /boot/boot.rc'. You can test that this is working as expected with a reboot 'sudo shutdown -r now'

Thanks Dave - glad you like it. And thanks very much for these links - it's great to have options (and understanding WHY makes a big difference!). I don't really know which option might be preferable, but maybe someone will post the answer here for us :)

as a linux sysadmin , the sudo update-rc.d sshd defaults is the more preferable (and correct) way of enabling ssh (and most other services) at startup, as it will apply on most (if not all) linux/unix systems. the cp /boot/boot_enable_ssh.rc.....is very raspberry pi specific.

Hi, thanks for the tutorial. I followed it and I found that :1 it's not the port used by the server to connect to clients, but the DISPLAY to use.The port is specified by the switch -rfbport. This last is the port to forward.

One query on this (as a Linux newbie, apologies if I've missed something obvious or basic). As a regular user of Ultra VNC to connect to PCs remotely, I'm used to the remote screen duplicating the host screen, but although I am controlling the Pi over VNC, it looks as if I'm controlling a virtual screen, as nothing on the screen, keyboard or mouse connected directly to the Pi is following what I'm doing on the remote PC and vice versa. This causes problems when the Pi goes into screensaver mode and the CPU usage goes up to 100%, resulting in slow response on the VNC connection. Activity on the remote PC doesn't bring it out of screensaver mode.

I'm guessing it's something to do with the way I've got VNC set up on the Pi, as I'm not familiar with launching VNC from the command line - something to do with the :1 display selection perhaps?

Yes, you should be able to do this. Take a look at my post on how to start VNC automatically - http://myraspberrypiexperience.blogspot.co.uk/2012/08/start-vnc-automatically.html. This should start it when booting up and should use your main display.

Thanks!Works like a charm... Following your tutorial made me have my raspi on screen very fast. Thanks for sharing!

As a side note for those using a linux box like myself, after having the "boot.rc" file in place, I've used the ssh shell ("ssh @") and "vinegar" as VNC client (both standard in ubuntu) to follow your post

I just got my RPi a week ago and using the 2012-07015-wheezy image, I get ssh loaded at boot up, so I was able to skip most of the first part of this tutorial.But the rest of it was very useful.As a result, I now have VNC working on both Windows installed from:http://www.tightvnc.com/download.phpand Ubuntu 12.04 installed using:sudo apt-get install xtightvncviewer

With Windows, you get both Server and Service programs, but the one you need to run is Viewer.

I had the same issue as you - it looks like tightvnc doesn't allow you to do this. I think I found that x11vnc worked quite well, and allowed you to connect to the exact session that was running on your TV. When you started x11vnc you could specify a session, and you could connect to that session by specifying a port when connecting using VNC. I can't quite remember the exact details, but I'll see if I can dig them up for you.

Hi Rick, sorry for the delay in replying - I had a look, but couldn't find anything I've used before. I keep meaning to look into this to see if I can figure it out, but my pi has been spending more time on the shelf than powered on unfortunately!

I have tried several times to install tightvnc. It installs fine but when I connect to it, I get the following error: Xsession: unable to start X session..no home/pi/.xsession file. No session manager, no window managers, and no terminal emulators found.

Looking for solution to this as well ... error reads Xsession: unable to start X session --- no "/home/pi/.xsession" file, no "/home/pi/.Xsession" file, no session managers, no window managers, and no terminal emulators found; aborting.

Thanks for the answer, were trying to connect the raspbbery via 3G, it will use the cell phone as a router, so ill need to port forwarding the router meaning the cellphone?Have you done anything like that?

Great page, lots of useful info here any it all worked a dream thanks.

I have my pi plugged into my TV and wanted to use my laptop as a remote control - I assume when I connect to port 5901 I am connecting to a separate X instance which is why I cannot see my mouse control on the TV. Is there a way to connect to the same instance as the HDMI uses/views?

Hi Danny. I know what you're referring to - it's something I struggled with initially. Try connecting on port 5900 - from what I recall that's the initial X instance displayed on the TV, whereas the next X instances (not visible) would be 5901, 5902, etc.

I cracked it - I was running an instance of vncserver aswell which was listening also. I plugged a keyboard and mouse into the pi, started x11 and when I tried vnc again it connected again it connected tithe same view as the hdmi.

I haven't really tried this as so far I haven't had a need to access it remotely. Definitely something I see being useful. Going to sort out a new wireless card (current one has issues) - will see what I can find out.

Hi, I have just downloaded the Raspbian “wheezy” distro from the foundation site and looking at the boot partition from a linux box I realize I don't have the boot_enable_ssh.rc file there .Would it be possible for you to share its content so I can create the file?Regard's,Ben Lines,Cliclk on my link nitrotek.nl

I don't have the details to hand, but in the latest version of Wheezy there is actually a bootup screen that allows you to configure this. When you first boot up the image you'll be presented with a menu containing roughly 10 items, one of which will be to enable SSH. There are several other useful options available, including expanding your partition to fill your SD card, modifying the GPU/CPU memory split, setting the default boot behavior (boot into X) and checking for updates. This should let you do what you want, but if you still want the details let me know and I'll dig them out tonight.

I have MOST of this working, but the client on my Windows 8 PC keeps asking for a VNC password, but the Pi VNC server did not ask for one, so I appear to be stuck - blank does not wor. I tried shutting down the Pi server & re-starting it, but that did not prompt for a password. Can anybody tell me what I am doing wrong please?

Hi Guys,Great post and I have my Pi VNC server running.One thing that tricked me is the :1 port thing.When I look in the start up log /home/pi/.vnc/raspberrypi:1.logI notice my port number for connections is 5901So my remote host address in Tightvnc Client is10.1.1.1::5901 not 10.1.1.1::1 as was my first guess.Otherwise I was getting the follwoing message"no connection could be made because the target machine actively refused it"

just find a good video converter to help to do so, such as aiseesoft video converter for mac is such a tooll which I have been using for a long time for convert mts to mov for editing and replay. just have a try at: http://www.ivideotool.com/ . good luck!!

Hi, Would really appreciate if anyone has any info on this. Everything works fine for me up to the step "Connecting via UltraVNC". First, I don't have UltraVNC, I have Tight VNC, which seems to be basically the same thing. In my Tight VNC Viewer I'm entering my Raspberry Pi's IP followed by :1 (###.###.#.#:1). Problem is when I do that I get this error "Error in TightVNC Viewer: An attempt was made to access a socket in a way forbidden by its access permission." Does anyone know why I'm getting this / how to resolve?

Thanks for the post. Absolutely good for newbies to learn. Laptop display issue is a very frequent one. Lines in the display, dot marks in the display and cracks on the display are quite common. As a service center we know that it is a good source of profit. Canon Printer Service Centers in Chennai

Good post on working on laptop display. I have learned practically on how to change the laptop display but never fitted it live service. I am working as a trainee in a service center. Will get chance to do soon. Dell Laptop Service Centers in Chennai