How to Enable and Setup Raspberry Pi VNC?


This post may contain affiliate links/ads and I may earn a small commission when you click on the links/ads at no additional cost to you. As an Amazon Affiliate, I earn from qualifying purchases. Techsphinx also participates in the StationX Affiliate program. You can read my full disclaimer here.

In this guide, I will show you how to enable VNC on Raspberry Pi (including headless VNC setup) and connect to it remotely from Windows, Linux and Android devices.

VNC (Virtual Network Computing) is a graphical desktop-sharing system through which you can remotely control other devices (in this case – a Raspberry Pi) over the network.

There are other ways to remotely connect to Raspberry Pi such as using SSH. However, connecting through VNC can provide a full-fledged desktop experience as if you were connecting the Raspberry Pi to a TV screen or monitor using an HDMI cable.

Equipment Needed

Alternatively, you can purchase CanaKit Raspberry Pi 4 Extreme Kit that contains all the above-mentioned items.

Pre-requisites

Enable Raspberry Pi VNC

If you have a monitor or Raspberry Pi Screen connected, then you can easily enable the VNC service with just a few clicks.

1. Boot up your Raspberry Pi.

2. Click on the Raspberry Pi logo (on the top-left corner of the screen).

3. Navigate to Preferences and click on the “Raspberry Pi Configuration” from the drop-down.

Raspberry Pi Configuration

4. The Raspberry Pi configuration screen will open, from there navigate to the “Interfaces” tab.

5. Enable VNC and click on “Ok” to save changes.

Enable VNC Raspberry Pi Configuration

VNC service is now enabled on your Raspberry Pi.

Headless Raspberry Pi VNC setup

If you don’t have access to Monitor, TV or a Raspberry Pi touch screen display, then you may have to do some more work to enable the VNC service on your Raspberry Pi.

There are 4 steps involved before you can use VNC to connect to Raspberry Pi remotely:

  1. Enable SSH service in headless mode
  2. Configure WiFi settings in headless mode
  3. Connecting to the Raspberry Pi using SSH
  4. Enabling the VNC service

Let’s start with the First step.

1. Enable SSH Service

Note: These steps are intended for those who have already installed the Raspberry Pi OS. If you have not installed the OS yet, then you can enable SSH before writing the image to the SD card. You can find more information about that in my Enable SSH on Raspberry Pi guide.

Follow these steps to Enable SSH on Raspberry Pi in Headless mode:

1. Power off your Raspberry Pi, take out the SD card and plug it into a PC or Laptop using the SD card reader (Adapter).

2. Navigate to the SD card. You can use “File Explorer” in Windows or use the “cd” command in the terminal on a Linux or Mac machine.

3. In the root folder of the SD card, create a file called “ssh” without any extensions.

On Windows, right-click > New > Text document and name the file ssh. Remove the “.txt” extension.

Note: By default, Windows hides the extension of files. Click on “View” on the File Explorer and enable the “filename extensions” option.

On Linux, you can use the touch command.

touch ssh

While booting, the Raspberry Pi looks for a file called ssh, and if found, then the SSH service will be enabled automatically.

2. Configure WiFi Settings

SSH is enabled, but to connect to Raspberry Pi using SSH, you’ll need to connect to a network (through WiFi or Ethernet).

Note: If you are using Ethernet to connect to the network then skip this step and proceed with “Connecting to Raspberry Pi using SSH” step.

To configure WiFi settings on Raspberry Pi follow these steps:

1. Create another file called “wpa_supplicant.conf” in the “boot” (just as you created the ssh file). Once again, you can use the “File Explorer” on Windows or the “touch” command on Linux to create the file.

2. Open the newly created “wpa_supplicant.conf” file and add the following lines to it.

country=IN
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="Network_Name"
psk="Network_Password"
}

(Replace “Network_Name” and “Network_Password” with the actual WiFi network name and password. Also, change the country code according to your country.)

3. Save and close the file.

The Raspberry Pi will be automatically connected to the WiFi Network.

3. Connecting to the Raspberry Pi using SSH

Safely eject the SD card and plug it back into the Raspberry Pi. Once it is booted you can connect to Raspberry Pi remotely via SSH.

To connect to Raspberry Pi from another machine we need to know its IP address.

Find IP Address of Raspberry Pi from other Machine

Since you can’t access the Pi and you have used the headless way to enable SSH on Raspberry Pi, you have to use other tools on remote machines to find the IP address.

Make sure the other machine is also connected to the same network to which the Raspberry Pi is connected.

Using Angry IP Scanner (Windows)

1. Download, install and start Angry IP scanner.

2. Enter IP Range to scan and click on “Start”.

Angry IP scanner

3. Once the scan is complete, check the results of the scan to know the IP address of the Raspberry Pi.

Angry IP Scanner result

Using Nmap (Linux)

1. Install “nmap” on your Linux system.

On Ubuntu/Debian based systems run:

sudo apt install nmap
install nmap on Linux

On RHEL/Fedora based systems run:

sudo dnf install nmap

2. Next, use “nmap” to scan the network.

sudo nmap -sn 192.168.29.0/24

(Replace 192.168.29.0/24 with your IP address range and netmask.)

Nmap scan result for Raspberry Pi

Once you know the IP address, you can use it to connect to the Raspberry Pi via SSH.

Connect to Raspberry Pi using SSH from Linux

To connect to Raspberry Pi remotely via SSH using a Linux machine follow the steps:

1. Open the terminal on Linux Machine.

2. Use the SSH command to connect to Raspberry Pi:

ssh [email protected]

(Replace username and IP address accordingly)

ssh: Name of the command.
[email protected]: Name of the user that we are trying to access via SSH (in this case, the “pi” user) along with IP address of the Raspberry Pi. 

3. Hit enter and it will ask you to accept the RSA key when connecting for the first time. Type “yes” and hit enter.

4. Enter the password for the user on Raspberry Pi (in this case the password for the “Pi” user) and hit enter.

SSH to Raspberry Pi from Linux

Now, you will get the SSH session for the “pi” user in the terminal. You can now perform any task on your Raspberry Pi remotely.

Connect to Raspberry Pi using SSH from Windows

To connect to Raspberry Pi from a Windows machine follow these steps:

1. Download and install PuTTY SSH Client.

2. Start PuTTY and enter the IP address of the Raspberry Pi.

3. Click on SSH and make sure the port is set to 22.

4. Click on “Open” to start a new SSH session.

PuTTY to SSH into Raspberry Pi

5. You’ll be prompted to add the host key. Click on “Accept”.

PuTTY host verification

6. Enter the username and password to log in.

Login to Raspberry Pi using PuTTY

If you’ve done everything correctly, then you’ll be logged in to the Raspberry Pi via SSH. Now, you can run any commands from the Windows machine on the Raspberry Pi.

4. Enable the VNC service

Finally, it’s time for the last step, i.e. to enable the VNC service.

1. Type the following command to open the Raspberry Pi configurations screen:

sudo raspi-config

2. On the raspi-config screen, navigate to the “Interface options” using the arrow buttons of the keyboard and hit enter.

Interface Options Raspi-config

3. Next, select the “VNC” option and hit enter again.

Select VNC Raspi-Config

4. Select “<Yes>” on the “Would you like the VNC server to be enabled?” prompt.

Enable VNC

5. Hit Enter on the “The VNC server is enabled” confirmation box.

VNC Enabled on Raspberry Pi

6. Lastly, use the arrow keys to navigate and select “Finish” to close the raspi-config screen.

That’s it. VNC service is now enabled on your Raspberry Pi.

Connecting to Raspberry Pi using VNC

Now, time to connect to the Raspberry Pi using VNC. Here, I am going to show you how to connect to Raspberry Pi using Windows, Linux and Android.

Let’s start with Windows.

Connecting using Windows

1. Download and Install the RealVNC viewer program.

2. Open RealVNC and type the IP address of the Raspberry Pi and hit enter.

3. Enter the password for the user.

RealVNC Raspberry Pi Connect

4. Click on “OK”.

Connecting using Linux (Ubuntu/Debian)

1. RealVNC is also available for Linux. Download it from its official website.

2. Navigate to the downloaded directory and use the following command to install the downloaded package.

sudo dpkg -i VNC-Viewer-6.21.1109-Linux-x86.deb

(Replace “VNC-Viewer-6.21.1109-Linux-x86.deb” with the actual name of the downloaded file.)

install RealVNC Viewer on Ubuntu

3. Start the RealVNC viewer graphically from the applications menu or use the following command:

vncviewer

4. Enter the IP address of the Raspberry Pi and hit enter.

5. Enter the password of the user.

6. Click on “OK”.

Connecting using Android

RealVNC is also available as an Android App. You can download it from Play Store and connect to the Raspberry Pi by providing its IP address.

Additional Tips on Using VNC on Raspberry Pi

Change the default Password

For security purposes, it is recommended to change the default password of the “pi” user.

1. Navigate to Preferences > Raspberry Pi Configurations.

2. Click on “Change Password”.

Change password Raspberry Pi

3. Enter the new password and click ok.

Change Hostname

Instead of using an IP address, you can use the easy-to-remember hostname to connect to your Raspberry Pi remotely.

1. Navigate to Preferences > Raspberry Pi Configurations.

2. Set a hostname for your Raspberry Pi. The default is “raspberrypi”.

3. Click on “OK”.

Now, instead of IP, you can also use the hostname to connect to Raspberry Pi via SSH or VNC.

Conclusion

That’s it for enabling and setting up VNC on Raspberry Pi. If you have any questions, feel free to ask them in the comments.

Also, you can check out my other articles/guides related to Raspberry pi here.

If you like this post, then follow Techsphinx on Facebook and Twitter for more reviews, tricks, tips and tutorials.

This article needs update or correction? Report the issue here so I can update it.


Like it? Share with your friends!

Rahul R Nair

Rahul is obsessed with technology and electronic devices. He is also the founder of TechSphinx. Being a technophile, he is always busy doing some techy stuff or learning about the latest technologies. When not busy with his usual routine (staring at the computer screen) he likes to write and share his knowledge with the world.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x