VNC server on Raspberry PI: Simple and Secure Remote Working

Create VNC on Raspberry
Spread the love

This post will walk you through about, how to install VNC server on a Raspberry pi and how to run it on BOOT.

VNC (Virtual Network Computing) is a tool to access your desktop from any other computer.

The VNC client application is pre-installed in MacOS. Just select GO -> Connect to Server -> vnc://192.168.2.4:5901< your ip address of your machine>:<port number = 5901>

You may download VNC application for Windows, Android, iOS and even the Chrome application.

Before beginning installation of any software please type in the below command.

sudo apt-get update

Installing VNC by terminal

Type in the following command.

sudo apt-get install tightvncserver

Run VNC server (after the installation)

$vncserver
password:<type in the default password for VNC server>
re-enter password:<type in the default password for VNC server again>

Run VNC server on boot

  1. Create a file.
    • touch vncbootscript
  2. Open the file to edit by nano
    • sudo nano vncbootscript
  3. Copy the following script in the file.
    • #!/bin/sh
      # /etc/init.d/tightvncserver
      # Thanks to Neil Black at www.neil-black.co.uk/raspberry-pi-beginners-guide
      VNCUSER='pi'
      case "$1" in
       start)
       su $VNCUSER -c '/usr/bin/tightvncserver :1'
       echo "Starting TightVNC Server for $VNCUSER "
       ;;
       stop)
       pkill Xtightvnc
       echo "TightVNC Server stopped"
       ;;
       *)
       echo "Usage: /etc/init.d/tightvncserver {start|stop}"
       exit 1
       ;;
      esac
      exit 0
  4. Copy this file to init directory (To run this on boot).
    • sudo cp vncbootscript /etc/init.d
  5. Now give the executable permission to the file for all groups.
    • sudo chmod a+x /etc/init.d/vncbootscript 
  6. Update the rc file
    • sudo update-rc.d vncbootscript defaults
  7. Now restart your raspberry pi by the following command and the VNC server will run automatically on boot.
    • sudo reboot
  8. If you want to turn off the auto boot run, you may type in future.
    • sudo update-rc.d vncbootscript remove

I hope the above commands will help to run VNC server on your raspberry pi.

I will upload the video lesson soon in English and Hindi for your convenience.

For any questions and queries please leave your comments below.

For more reading-
Torrent Server on Raspberry Pi
Install Kodi on Raspbian: An amazing multimedia experience
Samba File Sharing Server

1 Comment

  1. Very useful… 🙂

Leave a Reply