Raspberry Pi configure screen sharing with VNC
I've spent the past week exploring what my Raspberry Pi can do. It makes a great little server as it's tiny and consumes negligible power, about 3.5 watts. Of course as with any Linux box, there is little need for a monitor, so I've configured VNC to work seamlessly on my Raspberry Pi.
Here's how:
1. Configure your Raspberry Pi with a static IP address.
2. Open LXTerminal and type
sudo apt-get install tightvncserver
Complete the setup as prompted
pi@raspberrypi:~$ vncserver
You will require a password to access your desktops.
Password:
Warning: password truncated to the length of 8.
Verify:
Would you like to enter a view-only password (y/n)? n
New 'X' desktop is raspberrypi:1
Creating default startup script /home/pi/.vnc/xstartup
Starting applications specified in /home/pi/.vnc/xstartup
Log file is /home/pi/.vnc/raspberrypi:1.log
3. Create a script to ensure that VNC starts at boot time.
Type: cd /etc/init.d
sudo pico tightvncserver
and add this to the file (you can copy and paste)
#!/bin/bash
### BEGIN INIT INFO
# Provides: tightvncserver
# Required-Start: $syslog
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: vnc server
# Description:
#
### END INIT INFO
#! /bin/sh
# /etc/init.d/tightvncserver
#
# Carry out specific functions when asked to by the system
case "$1" in
start)
su pi -c '/usr/bin/vncserver'
echo "Starting VNC server "
;;
stop)
pkill vncserver
echo "VNC Server has been stopped (didn't double check though)"
;;
*)
echo "Usage: /etc/init.d/blah {start|stop}"
exit 1
;;
esac
exit 0
4. Make the script executable
sudo chmod +x tightvncserver
5. Created the correct symbolic links for reboot and shutdown:
sudo update-rc.d tightvncserver defaults
6. Let's test the script. Kill the VNC service with this command:
sudo pkill Xtightvnc
7. And run the new script to start the VNC service:
sudo /etc/init.d/tightvncserver start
and you should see
New 'X' desktop is raspberrypi:1
Starting applications specified in /home/pi/.vnc/xstartup
Log file is /home/pi/.vnc/raspberrypi:1.log
Comments
Luis Martin
29 September 2012 - 3:05pm
Permalink
In the "stop" part of the
In the "stop" part of the script I had to use
pkill Xtightvnc
instead of
pkill vncserver.
Apart from that, everything worked great.
Thanks!
Brian Wiegold
7 October 2012 - 7:11pm
Permalink
VNC autostart
Brilliant tutorial
Thanks very much
visitor
22 October 2012 - 4:12pm
Permalink
Hmm, it all seemed to setup
Hmm, it all seemed to setup ok, but I'm getting connection refused from the client end.
port 5901 is open.. and my vnc log says:
22/10/12 16:03:29 Xvnc version TightVNC-1.3.9
22/10/12 16:03:29 Copyright (C) 2000-2007 TightVNC Group
22/10/12 16:03:29 Copyright (C) 1999 AT&T Laboratories Cambridge
22/10/12 16:03:29 All Rights Reserved.
22/10/12 16:03:29 See http://www.tightvnc.com/ for information on TightVNC
22/10/12 16:03:29 Desktop name 'X' (raspberrypi:1)
22/10/12 16:03:29 Protocol versions supported: 3.3, 3.7, 3.8, 3.7t, 3.8t
22/10/12 16:03:29 Listening for VNC connections on TCP port 5901
Font directory '/usr/share/fonts/X11/Type1/' not found - ignoring
Font directory '/usr/share/fonts/X11/75dpi/' not found - ignoring
Font directory '/usr/share/fonts/X11/100dpi/' not found - ignoring
xrdb: No such file or directory
xrdb: can't open file '/home/pi/.Xresources'
22/10/12 16:05:52 Got connection from client 10.0.0.4
22/10/12 16:05:52 rfbProcessClientProtocolVersion: client gone
22/10/12 16:05:52 Client 10.0.0.4 gone
22/10/12 16:05:52 Statistics:
22/10/12 16:05:52 framebuffer updates 0, rectangles 0, bytes 0
Any ideas?
Lozzy
Add new comment