As before I'm connecting from my Windows 8 laptop. To connect to the Pi I've installed TightVNC on my laptop - you can download a free copy from here: TightVNC Downloads Page
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 as I am (I don't care about connecting a keyboard, mouse and HDMI cable to the R-Pi), that can be a little difficult. To get around this I've used again the PuTTY SSH client, as I did in my last post, which you can download here: PuTTY Downloads Page
The last thing you need to know is the Pi IP Address.
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. On the image on the left, it's easy to get the Pi IP (192.168.1.4), which I'll be using forthwith.
The configuration of the SSH server on the Pi is straightforward (see my last post).
Once I'm connected to the Pi, I needed to start the VNC server. If this is the first time you're doing this, you'll also need to install VNC first. 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.
Once installed, you'll need to start the VNC server. The command I've used is vncserver :1 -geometry 1280x800 -depth 16 -pixelformat rgb565. It also works with just the plain vncserver ...lol
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 logical port display 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 logical port display. 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. Once VNC server has been started the only thing left to do is connect. Start up TightVNC, type in the IP Address (or machine name) with a port of 1 and connect (this port is the logical port display I've used when starting the VNC process above):
We let magic work and voilá, the X Windows Session through the TightVNC:
NB: The procedure I've just described here has to be repeated every time I boot the Pi, which is not ideal. The ideal approach is to add the start of the TightVNC server to the init.d, so that the process starts before the login. For this I need to delve into some basic scripting.
First open a Terminal session on the Pi, or connect using SSH. A new terminal or SSH session will automatically start you off in your home directory of /home/pi. If you are not in this directory, change to it by typing:
- $ cd /home/pi
Then
cd to the .config directory by typing:
- $ cd .config
Note
the '.' at the start of the folder name. This makes it a hidden
folder that will not show up when you type 'ls'.
Issue the command below to create a new directory indide .config called 'autostart'.
Issue the command below to create a new directory indide .config called 'autostart'.
- $ mkdir autostart
cd
into that new directory by typing:
All that remains is to edit a new configuration file. So type the following command to open the nano editor on the new file:
- $ cd autostart
- $ nano tightvnc.desktop
Edit
the contents of the file with the following text.
- [Desktop Entry]
- Type=Application
- Name=TightVNC
- Exec=vncserver :1
- StartupNotify=false
Type
ctrl-X and then Y to save the changes to the file.
That's all there is to it. The next time you reboot, the VNC server will restart automatically.
On the next post I'll configure the Wi-Fi dongle, which is a must-have, if I want to have total mobility around the house.
Happy Hacking: You don’t learn to hack – you hack to learn...
MAAntão
That's all there is to it. The next time you reboot, the VNC server will restart automatically.
On the next post I'll configure the Wi-Fi dongle, which is a must-have, if I want to have total mobility around the house.
Happy Hacking: You don’t learn to hack – you hack to learn...
MAAntão




