Senin, 25 Juli 2016

VNC and Raspberry Pi

VNC and Raspberry Pi

VNC is now available for the Raspberry Pi:
  • Professional-class software from the original inventors of VNC.
  • VNC Server can run in different modes, for remote access in different circumstances.
  • Free VNC Viewer apps to connect in from virtually any device.
  • Enable the feature set that suits you best by applying a Free, Personal, or Enterprise license to VNC Server on your Pi.
All the commands in this article can be run over SSH if you’re setting up VNC remotely, unless otherwise stated.

Downloading, installing, and licensing VNC

  1. On your Pi, either download the VNC DEB package, or run the following commands:
    curl -L -o VNC.tar.gz https://www.realvnc.com/download/binary/latest/debian/arm/
    tar xvf VNC.tar.gz
  2. Install VNC Server (installing VNC Viewer as well means you can remotely access computers from your Pi, if you wish):
    sudo dpkg -i .deb [.deb]
  3. Apply a license key to VNC Server (typically received via email):
    sudo vnclicense -add

Getting connected

We recommend the following modes for VNC Server on the Pi:
Service Mode Virtual Mode
_images/raspberry-pi-service.png
VNC Server remotes your graphical desktop on the Pi. Connected VNC Viewer users see exactly what a person sitting in front of the Pi would see.
_images/raspberry-pi-virtual.png
VNC Server creates and remotes a virtual desktop. Connected VNC Viewer users therefore do not see what a person sitting in front of the Pi would see. Instead, they gain access to a persistent private workspace.
Set a password before you start VNC Server the first time. With a Free license, you must create a new VNC password:
sudo vncpasswd -service
With a Personal or Enterprise license, there’s nothing to do. Your pi username and password will work out-of-the-box.
There’s nothing to do here.
With a Free license, you’ll be prompted to create a new VNC password when you start VNC Server the first time (see below).
With a Personal or Enterprise license, your pi username and password will work out-of-the-box.
Start VNC Server:
# Debian 8 Jessie
sudo systemctl start vncserver-x11-serviced.service
# Debian 7 Wheezy
sudo /etc/init.d/vncserver-x11-serviced start
It may be more convenient to start VNC Server automatically when your power the Pi on:
# Debian 8 Jessie
sudo systemctl enable vncserver-x11-serviced.service
# Debian 7 Wheezy
sudo update-rc.d vncserver-x11-serviced defaults
Note VNC Viewer users won’t be able to connect in until you start your graphical desktop using startx. You can’t run this command over SSH, so the easiest thing to do is use raspi-config to Enable Boot to Desktop automatically.
Start VNC Server:
vncserver
Note you don’t (ever) have to start your graphical desktop using startx; VNC Server immediately creates the virtual desktop in memory and makes it available to VNC Viewer on the first available display, for example :1. This means you can run the Pi headless but still have visual access over VNC.
With a Free license, you can start VNC Server up to five times to create five separate virtual desktops. With a Personal or Enterprise license, you can start VNC Server as many times as your license permits.
To connect in over a local network, enter the private IP address of your Pi into VNC Viewer. You can find this out by running ifconfig, or from the VNC Server dialog:
_images/raspberry-pi-service-address.png
Note if your Pi is headless and the screen you see is too small, you can force a more convenient resolution.
To connect in over a local network, enter the private IP address and display number into VNC Viewer. VNC Server prints this information to the console when you start it:
_images/raspberry-pi-virtual-address.png
To connect in over the Internet, you must first configure any firewalls to enable VNC Server, port forward your router to the private IP address of the Pi, and enter the public IP address into VNC Viewer. More information.
To stop VNC Server in Service Mode:
# Debian 8 Jessie
sudo systemctl stop vncserver-x11-serviced.service
# Debian 7 Wheezy
sudo /etc/init.d/vncserver-x11-serviced stop