Tutorial: Using VNC on a Cloned SDCard for the Raspberry Pi
VNC is a great tool for the Raspberry Pi. If you need the Graphical User Interface (GUI), then you can use VNC on another computer and then you have your desktop right there! We use it for local computing using the GUI, but most often for working on computers often far away. For example, this is a VNC window on a SkyWeather system located in Palm Springs. We are logged in from SwitchDoc Labs about 1500 miles away. We also use this to maintain and tweak Project Curacao3.
What is VNC?
Virtual Network Computing (VNC) uses the Remote Frame Buffer protocol (RFB) to remotely control another computer. It transmits the keyboard and mouse events from one computer to another, relaying the graphical-screen updates back in the other direction, over a network.
VNC is platform-independent – there are clients and servers for many GUI-based operating systems and for Java. Multiple clients may connect to a VNC server at the same time. Popular uses for this technology include remote technical support and accessing files on one’s work computer from one’s home computer, or vice versa.
What the Problem with Cloned SD Cards and VNC?
When you clone an SC Card with VNC in the OS, you also clone the VNC credentials. These credentials are how the VNC server determines that you are who you say you are. So, especially if you are using one of the remote servers (so you don’t have to poke a hole in your firewall or router) that VNC vendors provide, then you have issues with the remote system being able to discriminate between two systems with the same remote. We use the excellent remote viewer from https://www.realvnc.com/ – see picture below.
We sell a cloned SDCard with the latest Raspberry Pi OS and all of the major SwitchDoc Labs software preinstalled for convenience, so we run into this occasionally.
How to Remove the VNC Credentials from a Cloned SD Card
It is really pretty easy. While there are lots of different ways that people propose to remove the VNC credentials, here is the easiest and most reliable way we have found. Open a terminal window and type:
sudo systemctl stop vncserver-x11-serviced sudo rm -rf /root/.vnc sudo systemctl start vncserver-x11-serviced
Now the next time you start VNC, it will establish new credentials.