Connect to the Pi Raspberry with VNC

You're angry with SSH ? Tired of having to connect keyboard and screen to your favorite raspberry ? Then access your Raspberry via the VNC service !

tightvnc logo

In the same way as Teamviewer, We will be able, via a local or even remote device, to connect to the interface screen of our Raspberry Pi.

  • For this, We need to install a software called tightvnc, free software, and free.

sudo apt-get install tightvncserver

  • Once the installed service, We have to start :

vncserver :1 -geometry 1280x800 -depth 16

Then, a bit of explanation is necessary :

vncserver :1 allows to launch the service on port 1, I will come back later.

-geometry 1280x800 to set the default output resolution when the remote connection.

-depth 16 sets the color ratio. (16/24/32 bits)

Be aware that there are other settings, less important, and they are not mandatory. one “vncserver :1” enough to start the service.

  • You are then asked to enter a password, which shall not exceed the 8 characters.You can also enter a read password only, which is far from being useful in the case of administration of Raspberry.

You found what to, Once the relieved raspberry local ip address, you connect via a VNC client, as VNC Viewer for example. Simply enter this address followed by the port :1 and you will have direct access !

For the little that you have a local IP, or a custom domain after using as this Inadyn in this article, just open the port for your service on the router.

You should know that in the case of tightvnc, the port to open is “590X” TCP/UDP, the X parameter corresponding to the figure you have earlier use to start your service. In this way, you are not obliged to open absolutely any VNC on your router ports, which allows to limit the intrusion.

Once open ports, for example, you can connect to your Raspberry via the 3G network with your mobile phone, by using the IP/domain name address, monitoring of the port in the form :1 or :5901.

Voilà, finally, Let's see how to ensure that the tightvnc service launches directly Raspberry Pi start.

  • For this, go to the following directory :

cd /home/pi/.config/autostart

  • There, create a file named “TightVNC.desktop” :

sudo nano tightvnc.desktop

  • Finally enter the following lines inside this script :

[Desktop Entry]

Type = Application

Name = tightVNC

Exec = vncserver :1 -geometry 1280×800 -depth 24

StartupNotify = false

  • Then save the file with a Ctrl O, Quit with Ctrl X.

You just have to restart your Raspberry ft. without its screen and connect via your main computer or office via your smartphone to see if your bebete small fine !

[Chris] For those who have a Mac, a VNC client is “Chicken of the VNC“. In mobility, RealVNC (Although paying) is an excellent product.

[Chris] Here's a script that can allow you to start VNC at the startup of the machine (Thanks to sebidouille). Modifiez le nom de l’utilisateur qui doit être utilisé par VNC en fonction de vos besoins.

# Provides: vncserver
# Required-Start: networking
# Required-stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description:

# /etc/init.d/vncboot VNCUSER='pi' case "$1" in start)
su $VNCUSER -c '/usr/bin/tightvncserver :1  -geometry 1280 x 800 - depth 24' echo "Starting TightVNC Server for $VNCUSER "
pkill Xtightvnc echo "TightVNC Server stopped"
echo "Use: /etc/init.d/vncboot {Start|stop}"
exit 1
esac exit 0

Rest to enable scripting :

sudo chmod   x /etc/init.d/vncboot sudo update - rc.d defaults vncboot
Like this article ? Bear with me on patreon!

You may also like...