• Home
  • Ubuntu 20.04
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 20.04
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Setup X11VNC Server on Ubuntu & LinuxMint

Written by Rahul, Updated on April 30, 2020

X11VNC is the popular VNC server for creating remote desktop connection and access the remote desktop. It works will almost all the desktop environments available for Ubuntu and Debian based systems. Using remote desktop connection we can connect any remote system and access graphical user interface and work. We can use any available vnc viewer like the tight vnc viewer, real vnc viewer or ultra vnc viewer.

X11VNC can be a better remote support software for you. This tutorial will help you to set up the x11vnc server on your Ubuntu, LinuxMint & Debian system and connect using vnc viewer from the client system.

Step 1 – Install X11VNC

X11vnc packages are available under default repositories. Open a terminal and run the following commands to update default repositories and install required packages.

sudo apt-get update
sudo apt-get install x11vnc net-tools

Step 2 – Create Password

Now create a password to connect using vnc viewer from the client system. This will not require any username to connect vnc.

x11vnc -storepasswd 

Enter VNC password: *********
Verify password: *********  
Write password to /home/rahul/.vnc/passwd?  [y]/n y
Password written to: /home/rahul/.vnc/passwd

Step 3 – Start X11VNC Server

After the successful installation of the x11vnc server on your system. Let’s start it using the following command. Change the parameters as per your setup.

sudo x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/rahul/.vnc/passwd -rfbport 5900 -shared

The VNC server will start on default port 5900. In case the port 5900 is busy with some other service, it will automatically select the next available port like 5901.

Step 4 – Connect from VNC Clinet

To connect to the server using VNC, you need a VNC client on your system. For this tutorial, I am using RealVNC viewer on our system. You can use any other client of your choice.

setup x11vnc on ubuntu

Step 5 – Setup AutoStart on Boot

Finally setup the auto start of x11vnc server on system boot. Create a x11vnc.conf file under /etc/init/ directory using following content.

sudo vi /etc/init/x11vnc.conf
# description "Start x11vnc on system boot"

description "x11vnc"

start on runlevel [2345]
stop on runlevel [^2345]

console log

respawn
respawn limit 20 5

exec /usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/rahul/.vnc/passwd -rfbport 5900 -shared

Conclusion

You can successfully configured VNC server on your Ubuntu or Debian system.

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

52 Comments

  1. Avatar Julian Reply
    January 30, 2021 at 9:55 pm

    I downloaded MX-19.3_386.iso, did no system updates and setup x11vnc with their installer was a real pain in the arse (can’t remote login) but this manual get it to work. THANK YOU!!!

  2. Avatar suresh Reply
    December 2, 2020 at 7:57 am

    I have set it up and it is working fine. Thank you so much for your guidance.

    Can you please help to enable file transfer from client to server and guide how to do file server.

  3. Avatar mercury0114 Reply
    October 30, 2020 at 10:59 am

    I installed a server following these instructions. But what to do on the client-side to connect? What’s the connect address if the server is hidden behind NAT?

  4. Avatar Jason B Reply
    July 9, 2020 at 7:39 pm

    When I try x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/{USER}/.vnc/passwd -rfbport 5900 -shared I get the following output spammed over and over:

    — x11vnc loop: 1 —

    — x11vnc loop: waiting for: 35530

    09/07/2020 12:35:54 passing arg to libvncserver: -rfbauth
    09/07/2020 12:35:54 passing arg to libvncserver: /home/{USER}/.vnc/passwd
    09/07/2020 12:35:54 passing arg to libvncserver: -rfbport
    09/07/2020 12:35:54 passing arg to libvncserver: 5900
    09/07/2020 12:35:54 x11vnc version: 0.9.16 lastmod: 2019-01-05 pid: 35530
    09/07/2020 12:35:54 -auth guess: failed for display=’localhost:10.0′

    — x11vnc loop: sleeping 2000 ms —

    Has anyone ran into this and if so found a solution for it?

    • Avatar Damien Reply
      August 7, 2020 at 5:38 am

      Have you installed net-tools as well?

    • Avatar Razi Reply
      August 18, 2020 at 9:38 am

      try to run without “sudo”

  5. Avatar John M Reply
    June 16, 2020 at 2:42 pm

    I am trying to get this to autorun on startup. I have done so once by another way, but I cannot remember how. Now I am trying to set this up on a different computer and cannot remember what I did. I am using Linus Mint. I am moving over to the newest 20 version.

    Everything works fine up to the point of setting up the autostart. Any help would be appreciated. I can’t seem to figure it out.

    John

    • Avatar Mark W Reply
      November 2, 2020 at 10:34 am

      This article suggests placing an x11vnc.conf file in /etc/init. That didn’t do anything for me. But I have success with this:
      1) Start x11vnc manually. I just launched it from the main menu – it’s under internet after a “normal” install
      2) Use the system tray gui to tweak settings, and then under Advanced – Actions – Settings use the save-settings command to create a config file “~/.x11vncrc”. Note that this does NOT save the password. It will still prompt you for it locally. Which is quite annoying if you are remote and need to reboot your home/office system.
      3) Use the command line “x11vnc -storepasswd” to generate the encrypted authentication file “~/.vnc/passwd”. Then edit the “~/.x11vncrc” file and uncomment the -rfbauth line and use the full path “/home//.vnc/passwd” as the parameter.
      4) Go to the main Mint menu – settings, open Startup Applications, and add the x11vnc app there. In the startup command field, use “x11vnc -rc /home//.x11vnc”. I also have had better success adding a 10-15 second delay in that same startup dialog box.

      If it is still running, go to the system tray, right-click the x11vnc icon, and choose Stop (or use any other means you choose to kill the process. Then while still in the Settings – Startup Applications screen, highlight the app and click the gear symbol at the bottom to test the launch. It should start in a few seconds. Then test connecting from a viewer to verify all is good.

      All this is assuming Cinnamon desktop, but it seems like I did essentially the exact same thing with XFCE. Not sure about other desktops. Works great when connecting from another Linux pc running Remmina. Works well enough from Windows with TightVNC viewer, but I have to play with scaling a bit because it tries to send all my active desktops/workspaces and multiple monitors vertically stacked and I really want to just see one workspace at a time like I would if I was actually looking at the screen locally. To tell the truth, I have switched over to AnyDesk for most of my remote access needs, but still have vnc running as a backup.
      Good luck

  6. Avatar Peter Reply
    May 30, 2020 at 7:38 pm

    Hi,
    Just installed Ubuntu 20.04.LTS and X11VNC wasn’t working using:
    $ sudo x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/rahul/.vnc/passwd -rfbport 5900 -shared
    the console was “spitting out” -auth guess: failed for display:’:0′

    I had to do extra steps:
    Disabled “Wayland” display manager by editing /etc/gdm3/custom.conf and setting WaylandEnable=false

    Execute:
    x11vnc -auth /run/user/1000/gdm/Xauthority -forever -loop -noxdamage -repeat -rfbauth /home/USERNAME/.vnc/passwd -rfbport 5900 -shared

    Also, the “autostart on Boot” doesn’t work.
    I’m using a 18.04 LTS fresh install upgraded to 20.04 LTS. So maybe this /etc/init/… is “deprecated”.

    Still trying to figure this one out.

  7. Avatar DIMM_V2 Reply
    May 4, 2020 at 11:37 am

    hi , i have multiples screens when im scrolling down (while im connected), how to fix that ?

    • Avatar DIMM_V2 Reply
      May 11, 2020 at 9:49 am

      –nocache

  8. Avatar Tiago Reply
    April 29, 2020 at 7:44 am

    Hello, I am trying to turn an old desktop into a server, I installed Ubuntu and now I want to have a vnc installed. The installation worked fine but I am stuck at the password, every time I try to create the password file it says it did so and it appears in the files but when I try to connect from a different device it always says that the password that I filled in is wrong. I tried 4 different passwords (removing things like @ . _) but it still gives the error message on the other device

    • Avatar Helper Reply
      April 30, 2020 at 2:03 pm

      When starting the server with this command:

      sudo x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/rahul/.vnc/passwd -rfbport 5900 -shared

      change the dir to your home dir, i.e. change rahul to your user

      • Avatar John Reply
        May 26, 2020 at 8:13 am

        To the author of the post – you should just change /home/rahul/.vnc/passwd to $HOME/.vnc/passwd

  9. Avatar Jeroen Reply
    April 25, 2020 at 10:48 pm

    Works still great…
    Set it up in 5 minutes. I would change it a little and use Caisy’s systemctl option.

  10. Avatar Bob Fryer Reply
    April 25, 2020 at 7:22 am

    I should add that I was working on (as mentioned updating all systems) and had installed Linux Mint 19.3 where VNC became the issue. It was working on my earlier systems.

    Anyhow, as mentioned working perfectly on Mint 19.3

    Regards
    Bob

  11. Avatar Bob Fryer Reply
    April 25, 2020 at 7:19 am

    Thank you to Rahul, Caisy and Mattg,

    Like others on this forum, there are so many sites with solutions that just don’t work with Mint 19.x (and a lot of time wasted).

    Due to this Corona lockdown, I have quickly had to rebuild my lab with all systems updated so that I can progress with some work, so the VNC is a very small part, but an important part for speed, if it was the only issue I was working on I would spend a few hours looking at the issue, but cannot, so vary much appreciate Rahul’s article and the other knowledgeable posters, particularly Caisy and Mattg as well as all the other comments

  12. Avatar Josh Davis Reply
    March 11, 2020 at 3:35 pm

    It didn’t work for me at first. The error I got was

    /tmp/fd.qUioJx: 1: /tmp/fd.qUioJx: netstat: not found
    11/03/2020 11:29:45 -auth guess: failed for display=’:0′

    The solution was to install netstat:

    sudo apt install net-tools

    • Rahul Rahul Reply
      March 12, 2020 at 6:33 am

      Thanks Josh. Your contribution will help other users.

  13. Avatar Amr Farouk Reply
    February 19, 2020 at 4:56 am

    I double Marco’s opinion.
    this is the best tutorial among at least 15 I went through.
    and by far as well

  14. Avatar ThumbOne Reply
    August 8, 2019 at 10:59 am

    I think it would be nice if you dedicated a liitle space to explaining your choice of options, what they all mean and do and why you choose them. It is by no means clear fro example why you elect to us -noxdamage and -repeat.

  15. Avatar Ron Reply
    March 26, 2019 at 6:10 pm

    I was able to find a solution to why I was not getting x11vnc server to work. You may need to have the
    All users may connect to this network checked in the general tab of the Network Connections manager.
    This enabled the IP to be loaded before the x11vnc service.

  16. Avatar ron Reply
    March 25, 2019 at 8:54 pm

    Thanks for your help. I am able to use vncviewer with your setup. It still will not load at the login prompt.
    Any ideas on what I need to do to get the boot up functionality working? I am using LM 19.1.

  17. Avatar caisy Reply
    January 8, 2019 at 1:55 am

    For AUTOSTART :

    1. make file x11vnc.service in /etc/systemd/system :
    sudo mcedit /etc/systemd/system/x11vnc.service (mcedit – my prefered editor , i’m sorry for vi :)))

    with text (change RAHUL for you name):

    [Unit]
    Description=x11vnc remote desktop server
    After=multi-user.target

    [Service]
    Type=simple
    ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/RAHUL/.vnc/passwd -rfbport 5900 -shared

    Restart=on-failure

    [Install]
    WantedBy=multi-user.target

    2. sudo systemctl daemon-reload
    sudo systemctl start x11vnc
    sudo systemctl status x11vnc

    3. if it’s worked
    sudo systemctl enable x11vnc.service

    et voila

    • Avatar Mark R. Reply
      January 22, 2019 at 4:27 pm

      This was very helpful and work great. Thanks!

    • Avatar Ryan Reply
      February 10, 2019 at 2:39 am

      Awesome, this worked perfectly for me. Thank you very much.

    • Avatar Jacky Woo Reply
      February 23, 2019 at 9:02 am

      Hi
      I am running into something strange that I could not work out:
      I have followed the installation in Lubuntu 18.04 and it works perfectly

      BUT Now; I am learning Ubuntu 18.04.2 LTS, install x11vnc the same way
      Could not start service using following command:
      sudo x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/jacky/.vnc/passwd -rfbport 5900 -shared

      Error below:

      23/02/2019 19:08:42 passing arg to libvncserver: -rfbauth
      23/02/2019 19:08:42 passing arg to libvncserver: /home/jacky/.vnc/passwd
      23/02/2019 19:08:42 passing arg to libvncserver: -rfbport
      23/02/2019 19:08:42 passing arg to libvncserver: 5900
      23/02/2019 19:08:42 x11vnc version: 0.9.13 lastmod: 2011-08-10 pid: 2185
      ^X23/02/2019 19:08:42 -auth guess: failed for display=’:0′
      23/02/2019 19:08:42 -auth guess: since we are root, retrying with FD_XDM=1
      23/02/2019 19:08:42 -auth guess: failed for display=’:0′

      — x11vnc loop: sleeping 2000 ms —
      ############
      so I ran it without sudo and it works:

      x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/jacky/.vnc/passwd -rfbport 5900 -shared

      Log in from windows RDC no problem.

      ##################
      But I am not able to get it auto start.
      ###########
      I used exactly CAISY method of systemctl
      it is NOT working in Ubuntu (It was working on Lubuntu)

      Error below:

      [email protected]:~$ sudo nano /etc/systemd/system/x11vnc.service
      [email protected]:~$ sudo chmod +x /etc/systemd/system/x11vnc.service
      [email protected]:~$ sudo systemctl –system daemon-reload
      [email protected]:~$ sudo systemctl start x11vnc
      [email protected]:~$ sudo systemctl status x11vnc
      ● x11vnc.service – x11vnc remote desktop server
      Loaded: loaded (/etc/systemd/system/x11vnc.service; disabled; vendor preset: enabled)
      Active: active (running) since Sat 2019-02-23 19:19:06 AEDT; 10s ago
      Main PID: 2603 (x11vnc)
      Tasks: 1 (limit: 4915)
      CGroup: /system.slice/x11vnc.service
      └─2603 /usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/jack

      Feb 23 19:19:15 jackyhp x11vnc[2603]: 23/02/2019 19:19:15 passing arg to libvncserver: /home/jacky/
      Feb 23 19:19:15 jackyhp x11vnc[2603]: 23/02/2019 19:19:15 passing arg to libvncserver: -rfbport
      Feb 23 19:19:15 jackyhp x11vnc[2603]: 23/02/2019 19:19:15 passing arg to libvncserver: 5900
      Feb 23 19:19:15 jackyhp x11vnc[2603]: 23/02/2019 19:19:15 x11vnc version: 0.9.13 lastmod: 2011-08-1
      Feb 23 19:19:15 jackyhp x11vnc[2603]: xauth: unable to generate an authority file name
      Feb 23 19:19:15 jackyhp x11vnc[2603]: 23/02/2019 19:19:15 -auth guess: failed for display=’unset’
      Feb 23 19:19:15 jackyhp x11vnc[2603]: 23/02/2019 19:19:15 -auth guess: since we are root, retrying
      Feb 23 19:19:15 jackyhp x11vnc[2603]: 23/02/2019 19:19:15 -auth guess: failed for display=’unset’
      Feb 23 19:19:15 jackyhp x11vnc[2603]: — x11vnc loop: sleeping 2000 ms —
      Feb 23 19:19:17 jackyhp x11vnc[2603]: — x11vnc loop: 5 —
      lines 1-18/18 (END)
      #################################
      try rc.local approach not working
      rc.local does not exist on this Ubuntu installation.
      ##############
      ################################
      adding xllvnc.conf do not work
      sudo nano /etc/init/x11vnc.conf

      # description “Start x11vnc on system boot”

      description “x11vnc”

      start on runlevel [2345]
      stop on runlevel [^2345]

      console log

      respawn
      respawn limit 20 5

      exec /usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/rahul/.vnc/passwd -rfbport 5900 -shared
      ############################

      Any Kind Person can help me here?
      Thanks in advance

      • Avatar cr Reply
        October 2, 2019 at 10:52 am

        I have the same problem, very annoying. On one fresh linux box it works flawless, on the other fresh linux box i have this very same issue.

    • Avatar Uncle Mike Reply
      May 19, 2019 at 5:27 pm

      Thank you Caisy, and of course thanks to Rahul

    • Avatar MattG Reply
      December 10, 2019 at 10:31 pm

      I had the same issue with running x11vnc when I tried the conf file. I setup the service file and could not get it to load. The issue I found was that I logged into my unbuntu desktop as user recorder but root was trying to run the service and attach to the desktop. This is what my service file looks like.

      I added the User=recorder and Group=recorder. The service then started at the user logged into the GUI and it worked!

      [Unit]
      Description=x11vnc remote desktop server
      After=multi-user.target

      [Service]
      User=recorder
      Group=recorder
      Type=simple
      ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/recorder/.vnc/passwd -rfbport 5900 -shared

      Restart=on-failure

      [Install]
      WantedBy=multi-user.target

      • Avatar Javier Reply
        March 13, 2020 at 8:58 am

        Thank you MATTG, I had the same issue on Ubuntu 18.04 with

        xauth: unable to generate an authority file name
        -auth guess: failed for display=’:0′
        -auth guess: since we are root, retrying with FD_XDM=1
        -auth guess: failed for display=’:0′

        Adding the User and Group options to the service file fixed it.

      • Avatar Martins Reply
        January 19, 2021 at 12:06 pm

        Adding User and Group fixed it for me as well.

    • Avatar roland albert roth Reply
      March 1, 2020 at 4:09 pm

      Thank you MATTG
      With your detail and explanation its working well (LunixMint 19.3)
      roland

    • Avatar Mark Reply
      August 15, 2020 at 8:46 pm

      This worked for me as well on Linux Mint 20, awesome!

  18. Avatar Marco Reply
    January 7, 2019 at 8:06 pm

    Thank you, after many tutorial, this work immediately with x11vnc. great!

  19. Avatar Scott Reply
    November 11, 2018 at 4:57 am

    I’ve followed the instructions herein and continue to receive the error message…’password check failed’. Suggestions?

    • Avatar Andrei P Reply
      December 27, 2018 at 12:25 am

      Hey, replace the command with the right username 😉

  20. Avatar batmunkh Reply
    January 16, 2018 at 7:33 am

    autostart isn’t working. have you checked autostart?

    • Avatar Jonas Reply
      December 13, 2018 at 11:01 am

      Dear Batmunkh,

      I am relatively new to linux and have just succeed get the VNC connection working. Nevertheless, I am also interested in having the autostart working. I already tried putting the command into “Startup Applications”, but it didn’t work. Would you be so kind to help me find where and how to check for the autostart?

  21. Avatar mark Reply
    October 1, 2017 at 12:49 pm

    you are a time and energy saver.thanks it worked

  22. Avatar Ranjith Kumar Reply
    May 15, 2017 at 9:09 am

    I tried following all your steps still its not working. When I try to see the VNC in browser it is not working. I tried localhost:5900 in browser?? Its not working??

    • Rahul Rahul K. Reply
      May 17, 2017 at 3:35 am

      Hi Ranjith,

      What error are you getting? Have you tried with vnc viewer application?

      • Avatar batmunkh Reply
        January 16, 2018 at 7:32 am

        autostart isn’t working. have you checked autostart?

    • Avatar sravan Reply
      July 25, 2017 at 5:31 pm

      Hi Rahul,

      I have X11vnc in docker container and am accessing this vnc server via noVNC on browser.

      Now my question is , not able to copy & paste to remote to local vice versa. Is it possible?
      if yes let me know.

  23. Avatar Mike Lieberman Reply
    May 13, 2016 at 8:46 am

    Nice and works – but if some other user is on the “server,” I can’t login. With other VNC servers I was, in the distant past, able to log in without controlling the user at the console. Is there a way to make this multi-user?

  24. Avatar Zarko Reply
    April 17, 2016 at 4:54 am

    Thanks! Your instructions work!

  25. Avatar sam Reply
    April 14, 2016 at 4:52 pm

    Hi, Bojangles,

    Please follow the below steps.
    its working for me.

    On Server
    Step 1-:
    Install the required x11vnc package in ubuntu.

    $ sudo apt-get install -y x11vnc
    Step 2-:
    Create a password for a user.

    $ x11vnc -storepasswd
    Output-:

    Enter VNC Password:
    Verify password:
    Write password to /home/user/.vnc/passwd? [y]/n y
    Password written to: /home/user/.vnc/passwd
    Step 3-:
    To run the vnc server on every start automatically. We have to open /etc/rc.local file.

    $ sudo nano /etc/rc.local
    Copy the below line to start vnc session automatically with system startup, paste it the line before the “exit 0”.

    sudo x11vnc -xkb -noxrecord -forever -noxfixes -noxdamage -display :0 -auth /var/run/lightdm/root/:0 -usepw &

  26. Avatar Wim Reply
    February 20, 2016 at 10:47 am

    Thanks, exactly what I was looking for.

  27. Avatar Bojangles Reply
    November 13, 2015 at 2:01 pm

    Thanks for your reply. I was able to resolve it by moving the password file outside of the home dir as you had specified. I moved it to “/etc” and now it works at the login screen. Thanks again.

  28. Avatar Bojangles Reply
    November 13, 2015 at 3:58 am

    Good stuff and exactly what I am looking for! But unfortunately this is not working for me. When I try to connect via VNC to my Linux Mint instance which is at the login screen I get the following error; “password check failed”. But if I sit in front of the computer and login and then try to connect via VNC it works fine. Any ideas why I cannot get this working via the login screen?

    • Rahul Rahul Reply
      November 13, 2015 at 6:32 am

      Hi,

      Use password you created with “x11vnc -storepasswd” command. System password is bit different than it.

      • Avatar roland albert roth Reply
        March 1, 2020 at 4:17 pm

        Dear RAHUL
        Thank you, step 1 to 4 is working great (LinuxMint 19.3). Step 5 don’t touched the automatic starting point.
        = manual starting point
        With the supplementation from CAISY it’s running great.

Leave a Reply Cancel reply

Popular Posts

  • How To Install Python 3.9 on Debian 10
  • How to Install Python 3.9 on CentOS/RHEL 8
  • Download Ubuntu 20.04 LTS – DVD ISO Images
  • Linux Run Commands As Another User
  • How to Check PHP Version (Apache/Nginx/CLI)
  • How To Install and Configure GitLab on Ubuntu 20.04
  • How to Check Ubuntu Version with Command or Script
  • How to Install PyCharm on Ubuntu 20.04
© 2013-2021 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy