Home Raspberry Pi Install VNC Viewer on Raspberry Pi with Kali Linux

Install VNC Viewer on Raspberry Pi with Kali Linux


Using a Raspberry Pi with Kali Linux installed on it can be a powerful, yet portable tool for ethical hackers and security analysts alike. If you are new to the game then you obviously have a bit to learn and fortunately you are in the right place.

Accessing your device remotely can add convenience along with portability. Imagine leaving your Raspberry Pi at a location or building where you plan on testing the vulnerability of the network. You can then access that Raspberry Pi if you install VNC Viewer on Raspberry Pi with Kali Linux. You could be sitting in the comfort of your own home or office while testing the vulnerability of a network miles away from you.


How to Install VNC Viewer on Raspberry Pi with Kali Linux

Since we are performing an action that requires you to have a Raspberry Pi along with an SD card with Kali Linux installed on it we are going to assume that you already viewed our article about how to install Kali Linux on Raspberry Pi 3 with 3.5 inch LCD Screen.

When your Raspberry Pi is properly configured with your Kali Linux installation the first thing that you need to do is make sure your installation is updated. You can update your Kali Linux installation by opening up a terminal and typing:

apt-get update

Now that everything is updated we need to install x11vnc. To install you just need to type into your terminal:

apt-get install x11vnc

After x11vnc is installed we are going to set a password that you will use to access your Raspberry Pi remotely. To set a password type in:

x11vnc -storepasswd

Install VNC Viewer on Raspberry Pi with Kali Linux-installing x11vnc

You will be prompted to enter your password and then verify it. It will ask if you want to write the password to /root/.vnc/passwd and you select yes.

After your password is set you need to run x11vnc before you can actually connect to your Raspberry Pi remotely. To start x11vnc you need to type the following into your open terminal:

x11vnc -ncache 10 -auth guess -nap -forever -loop -repeat -rfbauth /root/.vnc/passwd -rfbport 5900

I know what you are thinking. What do all these commands mean and why do I need them? We will go over the commands we use here but if you need to use other commands then you can visit this site for a full list of command line options.

  • -ncache: Caches the screen content for rapid retrieval which reduces “lag”.
  • -auth guess: Used to guess the XAUTHORITY file for the display
  • -nap: Monitors activity and if it is low take longer naps
  • -forever: Keeps listening for more connections rather than exiting as soon as the first client(s) disconnect.
  • -repeat: VNC clients are connected and VNC keyboard input is not idle for more than 5 minutes. This works around a repeating keystrokes bug (triggered by long processing delays between key down and key up client events: either from large screen changes or high latency).
  • -rfbauth passwd-file: Authenticates the password file
  • -rfbport port: TCP port for RFB protocol

Now that we have x11vnc running on our Raspberry Pi we need to download a program on our computer that we will be using to access our Raspberry Pi remotely. Head on over to RealVNC and download VNC Viewer and make sure that you download the correct version that corresponds to your operating system. After VNC Viewer is downloaded open it up and enter the details required to connect to your Raspberry Pi. You will need to enter the IP address of your device, followed by a colon, and the port that we will be connecting to.

Install VNC Viewer on Raspberry Pi with Kali Linux-vnc viewer gui


If you do not know the IP address of your Raspberry Pi you can use the following command in your terminal:


Now that we have details entered into the VNC Viewer GUI we will connect. When you connect you will first see a prompt regarding an unencrypted connection and you can just press “continue”. If you want a secure connection see securing VNC connection on Kali Linux with SSH.

Install VNC Viewer on Raspberry Pi with Kali Linux-unencrypted connection

Keep note that your VNC connection is not secure

Now you should see a window pop up that shows the login screen for Kali Linux. Input your username and password and the Kali desktop environment should load up. If you haven’t set a username and/or password for Kali yet then you will be using the default login credentials. The default username is “root” and the password is “toor”. Change screen resolution in Kali Linux on Raspberry Pi 3 if you are having issues with the screen size.


Install VNC Viewer on Raspberry Pi with Kali Linux is now successful but what if you don’t want to manually run x11vnc every time you plan on accessing your Raspberry Pi remotely? If you want x11vnc to auto-start every time you boot up your Raspberry Pi then we need create a new file.

Open up a terminal in Kali and navigate to the “bin” folder by typing:

cd /usr/local/bin

Now we will create a new file by typing:

nano sharex11vnc

With our new file open we need to enter the following:


x11vnc -ncache 10 -auth guess -repeat -nap -loop -forever -rfbauth ~/.vnc/passwd -desktop "VNC ${USER}@${HOSTNAME}"|grep -Eo "[0-9]{4}">~/.vnc/port.txt

# comment this out if you dont want a pop up telling you which port you're using

zenity --info --text="Your VNC port is 'cat~/.vnc/port.txt'"

After you have included the above text you need to save the file by pressing “Ctrl+x”, then press “y”, then “Enter”. This file will automatically run x11vnc when your Raspberry Pi boots up. Now we need to set permissions on this file that we just created by using the following command:

chmod 755 /usr/local/bin/sharex11vnc

Now we have to set x11vnc to auto-start on boot using the file we just created. In Kali navigate to Applications >> Settings >> Session and Startup.

Install VNC Viewer on Raspberry Pi with Kali Linux-session and startup location

When the “Session and Startup” box appears you need to click on the “Application Autostart” tab and click the “add” button. When the “Add application” box appears you need to enter a name (VNC Viewer or a name of your choice), a description (optional), and the command. The command needs to be entered as “x11vnc” without the quotes. When finished click the “OK” button and make sure that “x11vnc” is checked in the “Application Autostart” list. Then close the “Session and Startup” dialog box.

Install VNC Viewer on Raspberry Pi with Kali Linux-add x11vnc

This means a little chunk of extra screen makes the phone just less than 4mm wider, and around 2mm shorter, than the Note 4.


There is another application that you can install that allows you to copy and paste text between applications. This can be very beneficial and time-saving if you plan on using the copy and paste commands frequently.

You can install this application by opening up a terminal session in Kali and entering:

apt-get install autocutsel

After it is installed you need to navigate to Applications >> Settings >> Session and Startup again and add “autocutsel” to the list of auto-start applications using the same procedure for adding x11vnc.


  1. Very useful. Just a typo on “x11vnc -ncache 10 -auth guess -nap -forever -loop -repeat -rfbauth /root/.nvc/passwd -rfbport 5900” /root/.nvc/passwd instead of /root/.vnc/passwd

  2. VNC View seems to log me out after a minute and wont let me log back in until I reboot the PI and log in to the kali gui

    Any advice on this?

  3. Hi,

    Firstly, thanks a ton for making such useful topics and helping us out.

    I am stuck with Raspberry Pi3 loaded with Kali Linux and would want your help on the same.

    To explain you the scenario,:

    Raspberry Pi3 is loaded with Kali Linux (the latest version)
    Have connected the internal wireless to my home SSID, which is used to connect the raspberry (Kali Linux) to the rest of my network.
    Have configured this internal wireless with static ip address, in order to help headless setup of Raspberry Pi using VNC.
    I have a Alfa-AWUS036NHA installed on the Raspberry for monitor mode, which works like a charm.
    To do the labs and practice, i also have SSH configuration done for accessing the Kali Linux from my Desktop, which is on the same home SSID.

    The Main Problem:

    When I VNC into Raspberry Pi and if i do a right click in Kali Linux, the VNC connection drops and i am not able to retry the VNC again. It just says host refused connection.
    To overcome this, i need to power off the raspberry pi and repower it again to get a new VNC connection.

    The workaround:

    I have a 16inch Acer (P166HQL) monitor connected to the raspberry Pi using HDMI to VGA convertor.
    Actually, i have a VGA switcher in place, which helps me chose from the desktop PC or Raspberry Pi to stream on the Acer monitor.
    This is did, cause when i want to run wireshark directly from Kali linux to analyse a packet capture, i cannot do it from Putty(SSH).

    Issue with work around:
    The screen resolution was done as per your guide and it worked like a charm from the VNC, but when switched to the 16 inch Acer monitor via HDMI to VGA converter, the screen that comes up is 2 inches black portion on top and bottom.
    In short, the view is very small and i am not able to solve this.

    Request you to please help out on this.

  4. I’ve gone over this tutorial thoroughly, and I still run into the problem of not being able to reconnect after disconnecting. It will only connect once. After that, I get the message, “the port on which the computer is listening could not be contacted”.

    Do I have to add the port comment into the sharex11vnc file that i created? I noticed it wasn’t in your comments for making it auto-start, but it was in the original comments to start the vnc.
    And secondly, I am not being prompted to input my password when connecting.

  5. I left a comment, but it seems you deleted it instead of posting a reply. I really need some help here. I have used both of your tutorials, tightvnc, and this one, x11vnc. Tight only gives me view of terminal and grey screen, and doesn’t move my mouse and stuff in realtime. This one, which worked amazing when connected, but will only connect a single time. Even if the vnc is still running. Even if I stop, and restart vnc sservice. It always says ip address couldn’t be located, from the 2nd attempt on. It wont connect again until after a reboot of the OS. And yes, I have followed everything u said to the exact. I have tried solutions i found in comments, I have done an entire fresh install each time I followed a vnc tut. Please assist me


Please enter your comment!
Please enter your name here