I’ve had a Raspberry Pi since May 2012, when the first wave arrived. It’s a great device, but requires a display if not only connected to by SSH over a network. The Raspberry Pi has a HDMI output port, allowing it to be connected to a HDMI TV for display. It’s inconvenient to carry a TV around every time I wish to use my Raspberry Pi though, so I usually connect to it using a Remote Desktop connection from my Fedora 18 Linux laptop. This post gives instructions as to how I’ve set up this remote desktop connection.
Pre-requisites
You’ll need:
- A Raspberry Pi with the Raspbian OS installed on the SD card and a user account with password
- A monitor and HDMI cable to display the Raspberry Pi output
- A laptop to connect to the Pi
- A Remote Desktop client installed on the laptop
- An ethernet cable to connect from the laptop to the Raspberry Pi
- A VNC server already installed on the Raspberry Pi. To install a VNC server, run “sudo apt-get install tightvncserver” from a terminal on the Raspberry Pi whilst connected to a network. Then run “vncserver” from a terminal in the Raspberry Pi, where this will prompt you to set up a password for connecting to the Raspberry Pi with VNC.
Instructions
1) Connect your Raspberry Pi to the monitor, boot the Raspberry Pi and log in.
2) Open up a terminal and change directory to /etc/network (cd /etc/network)
3) First of all you’ll need to give the Raspberry Pi a fixed IP address. This is done by changing the /etc/network/interfaces file
Before changing any configuration file in /etc, you should always back up the original! Therefore copy /etc/network/interfaces to /etc/network/interfaces_old (cp /etc/network/interfaces /etc/network/interfaces_old). This way, if anything goes wrong then you can simply restore the original /etc/network/interfaces file (mv /etc/network/interfaces_old /etc/network/interfaces).
Change the contents of /etc/network/interfaces to:
auto lo iface lo inet loopback iface eth0 inet static address 192.168.200.100 network 192.168.100.0 netmask 255.255.255.0 broadcast 192.168.200.25
This gives the Raspberry Pi a fixed IP address of 192.168.200.100, which you’ll need for connecting to it by remote desktop.
4) Now create a new file on the Raspberry Pi at /etc/init.d/tightvncserver and give it permissions of 777 (sudo chmod 777 /etc/init.d/tightvncserver). Add the following contents to this new tightvncserver file:
### BEGIN INIT INFO # Provides: vncserver # Required-Start: networking # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Starts VNC # Description: ### END INIT INFO export USER='pi' eval cd ~$USER case “$1” in start) su -c 'vncserver -geometry 1366x768' $USER echo “Starting vncserver for $USER” ;; stop) pkill Xtightvnc echo “vncserver stopped” ;; *) echo “Usage: /etc/init.d/vncserver {start|stop}” exit 1 ;; esac exit 0
5) Run the command “sudo update-rc.d tightvncserver defaults” in a Raspberry Pi terminal. This will start automatically start a VNC server when the Raspberry Pi first boots up.
6) Now disconnect the Raspberry Pi from the monitor.
7) I connect to my Raspberry Pi from a Fedora 18 Linux desktop. After connecting the laptop to the Raspberry Pi with an ethernet cable, I then need to ensure that both machines are on the same network. In Fedora this is done by first disabling wireless on the laptop. I then navigate to the network settings page (Activities > System Tools > System Settings > Network on Fedora). I then select the Wired option and click Options to manually edit my wired network settings. This opens up a window, where I select the “IPv4 Settings” tab. I change the Method dropdown from “Automatic” to “Manual”, allowing me to manually set the wired IP address of my Fedora laptop. The Fedora IPv4 Settings window then has an Addresses table, where I click the “Add” button to add a new network entry.
I give this new entry the network settings of:
Address: 192.168.200.1
Netmask: 255.255.255.0
Gateway: 192.168.0.1
I then save these changes. These network changes ensure that the Fedora laptop and Raspberry Pi are on the same ad hoc network when connected by an ethernet cable. If you’re using another operating system to Fedora Linux, make the equivalent network setting changes to manually set the wired network address.
Image may be NSFW.
Clik here to view.
8) Start up your Remote Desktop client on your laptop. Connect with the protocol “VNC” and the IP address “192.168.200.100:5901”. You’ll be asked to enter the password you set for vncserver, then a window will open for your Remote Desktop connection to the Raspberry Pi.
Image may be NSFW.
Clik here to view.
You can now display your Raspberry Pi through a laptop without needing to use a HDMI monitor.
Image may be NSFW.
Clik here to view.
Clik here to view.
