topamax once a day

VNC setup on Raspberry Pi from Ubuntu

  

This tutorial will demonstrate how to setup and connect to a Raspberry Pi over VNC from Ubuntu. This process is easier if you have a display connected to the Raspberry Pi, but will also show the steps to connect with only Ethernet and power connected. It assumes you have Debian for Raspberry Pi installed on an SD card. If not, see RPi Easy SD card setup

Getting the IP address of the Raspberry Pi

The first step is to locate the Raspberry Pi on your network. If you have access to a display for your Raspberry Pi, this task is simple, in a terminal simply type:

ifconfig

All the network interface configurations will be displayed, including the IP address. However, if you don’t have a display for your Raspberry Pi, this isn’t an option. For this task, we can use the Linux nmap (Network Mapper) utility.

sudo apt-get install nmap

Then run a scan on your local network. Be change to the specifics of your own network.

nmap -sV -p 22 192.168.0.1-255

The results will display every machine that could be identified on port 22. The Raspberry Pi (running Debian) looks something like this:

Nmap scan report for 192.168.0.112
Host is up (0.033s latency).
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 5.5p1 Debian 6+squeeze2 (protocol 2.0)
Service Info: OS: Linux

Connecting over SSH

So we know that the Raspberry Pi has IP address: 192.168.0.112. Now we can ssh to it:

ssh pi@192.168.0.112

And you should receive a message like this:

The authenticity of host ’192.168.0.112 (192.168.0.112)’ can’t be established.
RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.
Are you sure you want to continue connecting (yes/no)?

Type yes at the prompt, then enter the password for the user pi, ‘raspberry’ by default. You should get a prompt that looks like this:

pi@raspberrypi:~$

Configuring VNC

Now that we have logged in to the Raspberry Pi, we can setup VNC for remote access. First we need to install the VNC server:

sudo apt-get install tightvncserver

Next, start the VNC server on the Raspberry Pi. Adjust the geometry paramater to your desired display size.

vncserver :1 -geometry 1024x600 -depth 16 -pixelformat rgb565

You will be prompted to create a password for VNC login. Once you do, you should see a line looking something like this:

New ‘X’ desktop is raspberrypi:1

Now, we can finally connect to the Pi with VNC. Back on the Ubuntu machine, install the VNC viewer client:

sudo apt-get install xtightvncviewer

Then connect to the running VNC server:

vncviewer 192.168.0.112:5901

To stop the VNC viewer, just close the application. To stop the VNC server, issue the following command (on the Raspberry Pi):

vncserver -kill :1

15 Comments

  1. works great!
    Thanks

  2. This isn’t by chance what the mobile labs website is running on is it?

  3. Daniel Keating

    Great article..you had another post that helped me find where I screwed up configuring apache for the pi. One last “topping” on this would be how to enable the vncserver start at boot (for us luddites)…

    • Daniel Keating

      NM–got it sorted out..combining syntax from about 3 other helpful sites got me a vncboot script that works lol

      • Hi Daniel, glad to hear you got it figured out! For anyone else still wondering, an easy way to accomplish this is by adding a line to /etc/init.d or .bashrc

        • Daniel Keating

          If you have a preferred method that’s easier than creating/ editing a vncboot.sh script in /etc/init.d that syntax would be appreciated :)

          • I think the easiest possible way is with a cron job set to run the command at startup. All you need to do is edit the global cron table:

            sudo crontab -e

            Then append a line to the end of the file like this (adjust as needed):

            @reboot su -c “vncserver :1 -geometry 1024×600 -depth 16 -pixelformat rgb565″ pi

  4. DungDibbler III

    THANK YOU!
    I wasn’t having much luck getting a VNC server going. I finally gave up and searched for someone doing what I was trying to do.
    Your guide was exactly what I needed. Had it up and running in about 2 minutes,

  5. Brilliant – thank you, just what I was looking for :)

  6. I followed your instructions exactly and it works perfectly. I love the fact that I can look for a solution to a problem and someone clever enough and good enough to spend their time to share their knowledge does so. Thank you.

  7. Worked great! Thanks for putting this together. I do appreciate your time effort, it helped a bunch

  8. Thanks a lot! Worked without problems!

Trackbacks/Pingbacks

  1. VNC setup on Raspberry Pi from Android | MitchTech - [...] This tutorial will demonstrate how to setup and connect to a Raspberry Pi over VNC from Android. This process …
  2. Rheoli Raspberry Pi drwy VNC o beiriant Ubuntu « Ubuntu Cymraeg - [...] Raspberry Pi drwy VNC o beiriant Ubuntu Dyma gyfarwyddiadau defnyddiol a hawdd i ddilyn am sut i …

Leave a Reply