Remotely control your Raspberry Pi with TightVNC

vncpilogo

Whether you’re a Linux guy pounding away on the keyboard in a Bash shell, or you’re a Windows guy automating specific tasks in PowerShell, we can all agree that the CLI is king. If you think “The GUI is where it’s at, bro. It’s all you need.”, or you’re one of those that’s stubbornly shying away from any command-line environment, then you’ll be severely behind almost everyone if you work in any IT-related administrator or engineer position.

Sometimes, though, there’s times when the GUI is necessary. Microsoft struck a home run when they developed RDP, but if you need to remote into a desktop environment on a Linux or Mac OS, you’ll need something like VNC

I was recently working on one of my Raspberry Pi’s and needed to troubleshoot an audio issue when streaming to a Bluetooth speaker. Testing specific audio levels and switching between different audio devices was obviously more convenient in a desktop environment, so I decided to set up VNC on this Pi using TightVNC, a free and lightweight VNC software that can be easily installed in Raspbian. Follow these quick instructions if you’d like to do the same.

Install TightVNC Server on your Raspberry Pi

Note: This is all assuming that you’re already running Raspbian on your Raspberry Pi

1. Once logged into the desktop, open up the Terminal (you can also remotely SSH into the Pi).

2. Before we install the TightVNC server, let’s make sure we’re up-to-date.

sudo apt-get update –y
sudo apt-get upgrade –y

3. Install the TightVNC Server software!

sudo apt-get install tightvncserver

4. Once that’s installed, type the following to start it.

vncserver :1

It’ll tell you that it requires a password to access your desktops. Choose any password that’s 8 characters or less. You can see below that it truncated the password down to 8 characters since it surpassed that.

1
It’s blurry because I forgot to screenshot this so I stole it from a YouTube video.

5. Your VNC server should be up and running now. If you don’t make this start at boot, though, it’d be kind of a pain in the ass since you’d have to type that command every time the RPi boots up. Let’s fix that.

sudo nano /etc/rc.local

6. From here, put the following in the line between fi and exit 0. Your screen should look like mine below.

su - pi -c '/usr/bin/vncserver :1'

2

Hit Ctrl+X, then Y and Enter to save and exit.

7. Reboot your Raspberry Pi.

sudo reboot

8. Once your Pi is back up, open up the Terminal again (or SSH back into it) and then verify the VNC server is up and running.

vncserver :1

3
If it’s saying the same as mine above, then congrats! You can now VNC into your Raspberry Pi using whatever VNC client you prefer.

 

Connecting to your Raspberry Pi using a VNC Client

1. If you don’t have (or know) what VNC client to use, you can download VNC Viewer from RealVNC here for free. I’m a massive fan of mRemoteNG, but for the simplicity of this tutorial, we’ll use VNC Viewer.

2. Once VNC Viewer is up and running, type out the IP address of your Pi followed by :5901 in the address bar. Press Enter and your screen should look like mine.

4

This is basically warning you that your credentials will be encrypted but all data after that won’t be. Click Continue.

3. Type in the password you made when you first launched “vncserver :1” and click OK.

5

4. You should now successfully be connected to your Raspberry Pi using VNC!

6

That’s it! Now if you want to use your Raspberry Pi as a headless server (or don’t want to do the excruciating work of getting out of your seat and hooking up a monitor, keyboard, and mouse to your Pi), you can now just remotely connect to your desktop environment.

Remotely control your Raspberry Pi with TightVNC