Raspberry Pi 3 Cookbook for Python Programmers
上QQ阅读APP看书,第一时间看更新

How to do it...

  1. First, we need to install the TightVNC server on Raspberry Pi with the following commands. It is advisable to run an update command first to get the latest version of the package you want to install, as follows:
sudo apt-get update
sudo apt-get install tightvncserver  
  1. Accept the prompt to install and wait until it completes. To start a session, use the following command:
vncserver :1  
  1. The first time you run this, it will ask you to enter a password (of no more than eight characters) to access the desktop (you will use this when you connect from your computer).

The following message should confirm that a new desktop session has been started:

New 'X' desktop is raspberrypi:1  

If you do not already know the IP address of Raspberry Pi, use hostname -I and take note of it.

Next, we need to run a VNC client. VNC Viewer is suitable program, which is available at http://www.realvnc.com/ and should work on Windows, Linux, and OS X.

When you run VNC Viewer, you will be prompted for the Server address and Encryption type. Use the IP address of your Raspberry Pi with :1. That is, for the IP address 192.168.1.69, use the 192.168.1.69:1 address.

You can leave the Encryption type as Off or Automatic.

Depending on your network, you may be able to use the hostname; the default is raspberrypi, that is raspberrypi:1.

You may have a warning about not having connected to the computer before or having no encryption. You should enable encryption if you are using a public network or if you are performing connections over the internet (to stop others from being able to intercept your data).