How to setup x11vnc to access with graphical login screen?











up vote
43
down vote

favorite
28












I have a server running Ubuntu 12.10 and need to be able to remote to this server without being logged-in.



I have found many solutions, but none seem to work with 12.10.



Can anyone give me step-by-step instructions on how to configure x11vnc to start as a service (prior to user login) so that when connecting with VNC I will be presented with a graphical login screen?



I'm new to Linux so please give as much detail as possible in your responses/comments.



Thanks










share|improve this question
























  • The amount of all these commands and configurations that an average user needs to do just to connect to a remote computer's screen is just ridiculous. On Windows, it just works... with a few mouse clicks, although remote desktop feature only works on expensive editions. I have spent a few hours, and I still could not make VNC start automatically. This is why Linux will remain unpopular OS for average users... (Please do not point things like "Linux is used in Android!" or something. Words have different meanings in different context. You know what "Linux" I mean in this context.)
    – Damn Vegetables
    Jun 20 at 15:14

















up vote
43
down vote

favorite
28












I have a server running Ubuntu 12.10 and need to be able to remote to this server without being logged-in.



I have found many solutions, but none seem to work with 12.10.



Can anyone give me step-by-step instructions on how to configure x11vnc to start as a service (prior to user login) so that when connecting with VNC I will be presented with a graphical login screen?



I'm new to Linux so please give as much detail as possible in your responses/comments.



Thanks










share|improve this question
























  • The amount of all these commands and configurations that an average user needs to do just to connect to a remote computer's screen is just ridiculous. On Windows, it just works... with a few mouse clicks, although remote desktop feature only works on expensive editions. I have spent a few hours, and I still could not make VNC start automatically. This is why Linux will remain unpopular OS for average users... (Please do not point things like "Linux is used in Android!" or something. Words have different meanings in different context. You know what "Linux" I mean in this context.)
    – Damn Vegetables
    Jun 20 at 15:14















up vote
43
down vote

favorite
28









up vote
43
down vote

favorite
28






28





I have a server running Ubuntu 12.10 and need to be able to remote to this server without being logged-in.



I have found many solutions, but none seem to work with 12.10.



Can anyone give me step-by-step instructions on how to configure x11vnc to start as a service (prior to user login) so that when connecting with VNC I will be presented with a graphical login screen?



I'm new to Linux so please give as much detail as possible in your responses/comments.



Thanks










share|improve this question















I have a server running Ubuntu 12.10 and need to be able to remote to this server without being logged-in.



I have found many solutions, but none seem to work with 12.10.



Can anyone give me step-by-step instructions on how to configure x11vnc to start as a service (prior to user login) so that when connecting with VNC I will be presented with a graphical login screen?



I'm new to Linux so please give as much detail as possible in your responses/comments.



Thanks







server vnc






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 17 '12 at 19:00









Salem

17k65082




17k65082










asked Dec 17 '12 at 18:27









user115250

216143




216143












  • The amount of all these commands and configurations that an average user needs to do just to connect to a remote computer's screen is just ridiculous. On Windows, it just works... with a few mouse clicks, although remote desktop feature only works on expensive editions. I have spent a few hours, and I still could not make VNC start automatically. This is why Linux will remain unpopular OS for average users... (Please do not point things like "Linux is used in Android!" or something. Words have different meanings in different context. You know what "Linux" I mean in this context.)
    – Damn Vegetables
    Jun 20 at 15:14




















  • The amount of all these commands and configurations that an average user needs to do just to connect to a remote computer's screen is just ridiculous. On Windows, it just works... with a few mouse clicks, although remote desktop feature only works on expensive editions. I have spent a few hours, and I still could not make VNC start automatically. This is why Linux will remain unpopular OS for average users... (Please do not point things like "Linux is used in Android!" or something. Words have different meanings in different context. You know what "Linux" I mean in this context.)
    – Damn Vegetables
    Jun 20 at 15:14


















The amount of all these commands and configurations that an average user needs to do just to connect to a remote computer's screen is just ridiculous. On Windows, it just works... with a few mouse clicks, although remote desktop feature only works on expensive editions. I have spent a few hours, and I still could not make VNC start automatically. This is why Linux will remain unpopular OS for average users... (Please do not point things like "Linux is used in Android!" or something. Words have different meanings in different context. You know what "Linux" I mean in this context.)
– Damn Vegetables
Jun 20 at 15:14






The amount of all these commands and configurations that an average user needs to do just to connect to a remote computer's screen is just ridiculous. On Windows, it just works... with a few mouse clicks, although remote desktop feature only works on expensive editions. I have spent a few hours, and I still could not make VNC start automatically. This is why Linux will remain unpopular OS for average users... (Please do not point things like "Linux is used in Android!" or something. Words have different meanings in different context. You know what "Linux" I mean in this context.)
– Damn Vegetables
Jun 20 at 15:14












8 Answers
8






active

oldest

votes

















up vote
38
down vote













Install x11vnc:



sudo apt-get install x11vnc


Create a password for your user:



x11vnc -storepasswd


If you have ssh setup you can use it to start x11vnc assuming you are logged in already, but remember to tell it to use your password file:



x11vnc -usepw


If you are not logged in you will get an error with the explanation:



If NO ONE is logged into an X session yet, but there is a greeter login
program like "gdm", "kdm", "xdm", or "dtlogin" running, you will need
to find and use the raw display manager MIT-MAGIC-COOKIE file.
Some examples for various display managers:

gdm: -auth /var/gdm/:0.Xauth
-auth /var/lib/gdm/:0.Xauth
kdm: -auth /var/lib/kdm/A:0-crWk72
-auth /var/run/xauth/A:0-crWk72
xdm: -auth /var/lib/xdm/authdir/authfiles/A:0-XQvaJk
dtlogin: -auth /var/dt/A:0-UgaaXa


Assuming you are using lightdm for the login you can fix this problem you can start x11vnc with the command:



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


I am not sure this is the best idea to run x11vnc as root. Maybe someone could edit with a way to access the login without using sudo.



Once this is running you should be able to connect using a vnc client such as krdc (for KDE). You might want to use GNU Screen to keep x11vnc running without needing the ssh session open



I was able to figure this out using http://ubuntuforums.org/showthread.php?t=2039022.



Here is a sample upstart job you can use to make it run at startup. It needs to be put in /etc/init/x11vnc.conf. (Note that newer versions of Ubuntu use systemd so see the other answer that has a sample systemd config):



# description "start and stop x11vnc"

description "x11vnc"

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

console log
#chdir /home/
#setuid 1000
#setgid 1000

respawn
respawn limit 20 5

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


Once you have made this file you can start it by running:
sudo start x11vnc
You can check the log at: /var/log/upstart/x11vnc.log






share|improve this answer



















  • 1




    You can run x11vnc as a normal user, no problem. For example: ssh to the host and run x11vnc -safer -forever -display :0 2>&1 & in a tmux session (good practice), it'll run under $USER.
    – Terry Wang
    Jul 17 '13 at 5:43












  • Also, just for reference, in order to change the viewport: superuser.com/questions/270608/…
    – Wtower
    Dec 19 '14 at 9:25






  • 2




    This doesn't explain how to have it auto start as requested (and is a common requirement for such a feature)
    – LovesTha
    Feb 25 '15 at 21:39






  • 1




    See here for a full list of x11vnc options. It took me a long time to find this: karlrunge.com/x11vnc/x11vnc_opts.html
    – Gabriel Staples
    Sep 7 '16 at 1:55






  • 1




    And see here for an excellent tutorial on setting this up on a Raspberry Pi with auto-start at boot: megaleecher.net/Raspberry_Pi_VNC_Setup
    – Gabriel Staples
    Sep 7 '16 at 1:56


















up vote
33
down vote













The above answers solve the problem, though a couple of amendments for versions of Ubuntu with systemd (15.04+), as follows:




  • Take advantage of new -auth guess functionality in x11vnc - which helps!

  • Update for systemd (not upstart)


Run the following to install:



sudo apt-get install x11vnc
sudo x11vnc -storepasswd yourVNCpasswordHERE /etc/x11vnc.pass
# for Ubuntu 15.04+
sudo nano /lib/systemd/system/x11vnc.service
# for Ubuntu 16.10+
sudo nano /etc/systemd/system/x11vnc.service


Insert this into the file:



[Unit]
Description="x11vnc"
Requires=display-manager.service
After=display-manager.service

[Service]
ExecStart=/usr/bin/x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :0 -auth guess -rfbauth /etc/x11vnc.pass
ExecStop=/usr/bin/killall x11vnc
Restart=on-failure
Restart-sec=2

[Install]
WantedBy=multi-user.target


Then, start with:



sudo systemctl daemon-reload
sudo systemctl start x11vnc


And ensure the service starts on boot:



sudo systemctl enable x11vnc





share|improve this answer























  • Referenced bbs.archlinux.org/viewtopic.php?id=168756 for some advice on Requires/Afters params
    – babelmonk
    Sep 22 '15 at 9:48






  • 2




    why isn't this answer marked as the correct answer?
    – Cybex
    Jan 2 '17 at 11:19






  • 1




    If there is no display at all, then one may want to set arbitrary resolution: sudo xrandr --fb 1920x1080.
    – Orient
    Jul 26 '17 at 7:55






  • 2




    It is not a given the x11vnc will work immediately. It would be a good idea to provide a testing command before commiting to a service that restarts on failure every 2 seconds. I'm using lightdm and xfce4 on a headless cloud Ubuntu 17.10 server. Restart-sec should be RestartSec
    – Ray Foss
    Dec 21 '17 at 17:45








  • 1




    Ubuntu 18.04 also seems to want RestartSec rather than Restart-sec.
    – Scott Willeke
    Jul 7 at 15:48


















up vote
14
down vote













Here's how:





  1. Install the X11VNC server (or through Ubuntu
    Software Center -> X11VNC Server)



    sudo apt-get install x11vnc



  2. Create a VNC password file.



    sudo x11vnc -storepasswd yourVNCpasswordHERE /etc/x11vnc.pass



  3. Create a job file in the editor nano (or gedit, leafpad etc.).



    sudo nano /etc/init/x11vnc.conf



  4. Paste this into the file:



    start on login-session-start

    script

    /usr/bin/x11vnc -xkb -forever -auth /var/run/lightdm/root/:0 -display :0 -rfbauth /etc/x11vnc.pass -rfbport 5900 -bg -o /var/log/x11vnc.log

    end script


  5. Save the file. You created a job for the Upstart event login-session-start.


  6. Restart Ubuntu.


That's it! You should now be able to connect with any VNC client even before login.






share|improve this answer























  • But how do you get it to work when lightdm doesn't create the auth file till a monitor is connected?
    – LovesTha
    Feb 25 '15 at 21:37










  • @didibus I've been trying to do this in Lubuntu, but x11vnc fails to autostart every time. It won't even start as a service, for that matter. File syntax is correct and I can start x11vnc from the shell just fine. What am I missing?
    – linuxgringo
    Jun 21 '15 at 14:10










  • This works on Lubuntu too. Specifically, LeMaker's version of Lubuntu for the Banana Pi.
    – AaronD
    Mar 1 '16 at 21:05


















up vote
2
down vote













babelmonks answer as a bash script, copy and save as x11vnc.sh & run with sudo bash /path/to/file/x11vnc.sh (sorry dont have enough rep to post a comment)



#!/bin/bash
#install x11vnc & set password
apt-get install x11vnc -y
x11vnc -storepasswd 123456 /etc/x11vnc.pass
#create config file for system service
cat > /lib/systemd/system/x11vnc.service <<-EOF
[Unit]
Description="x11vnc"
Requires=display-manager.service
After=display-manager.service

[Service]
ExecStart=/usr/bin/x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :0 -auth guess -rfbauth /etc/x11vnc.pass
ExecStop=/usr/bin/killall x11vnc

[Install]
WantedBy=multi-user.target
EOF
#restart new services & enable on boot
systemctl daemon-reload
systemctl start x11vnc
systemctl enable x11vnc





share|improve this answer





















  • If you want to improve another answer, please suggest an edit to it and don't create a new answer.
    – David Foerster
    Jan 3 '16 at 9:31










  • Will happily add this to mine if you'd like to create an edit @nix-badweasel
    – babelmonk
    Jan 3 '17 at 13:36




















up vote
1
down vote













Use my script for easy set up: installvncubuntu1604.sh



Usage:



chmod +x ./installvncubuntu1604.sh; sudo ./installvncubuntu1604.sh





share|improve this answer






























    up vote
    1
    down vote













    Here is a config works for sddm (for KDE 5). Currently, -auth guess does not work for sddm, the auth file is different every time, so we need something like -auth /var/run/sddm/*.
    The service looks like,



    [Unit]
    Description="x11vnc"
    After=multi-user.target

    [Service]
    ExecStart=/bin/sh -c "/usr/bin/x11vnc -xkb -noxrecord -display :0 -auth /var/run/sddm/* -rfbauth /etc/x11vnc.pass"
    ExecStop=/usr/bin/killall x11vnc

    [Install]
    WantedBy=multi-user.target


    I have to put it after multi-user.target, if after display-manager.service, x11vnc cannot find auth file, maybe sddm generates auth file later. This is tested on Manjaro 18.






    share|improve this answer




























      up vote
      0
      down vote













      I use my own shell: https://github.com/dvdvideo1234/UbuntuBatches/tree/master/x11VNC



      start on login-session-start

      script

      sudo /usr/bin/x11vnc -xkb -auth /var/run/lightdm/root/:0 -noxrecord -noxfixes -noxdamage -rfbauth /var/srv/x11vnc/x11vnc.pass -forever -bg -rfbport <your_port> -o /var/srv/x11vnc/x11vnc.log

      end script


      into the file:



      /etc/init/x11vnc.conf


      It makes it auto-start on boot, even on the logon screen it asks for a password.






      share|improve this answer






























        up vote
        0
        down vote













        Install x11vnc package



        #sudo apt-get install x11vnc


        Then set the password



        #x11vnc -usepw


        Then create startup script for x11vnc



        #sudo nano /etc/x11vnc.sh


        In File:



        /usr/bin/x11vnc -bg -forever -shared -reopen -usepw


        Then save



        #sudo chmod 777 /etc/x11vnc.sh


        Then add the script file to Control Center=>Startup Application
        Then Click Add



        > Name-----------x11vnc


        > Command-----<map the script file



        > Comment------service


        This is must be required to add for all user



        This will run after user login only






        share|improve this answer





















          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "89"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f229989%2fhow-to-setup-x11vnc-to-access-with-graphical-login-screen%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          8 Answers
          8






          active

          oldest

          votes








          8 Answers
          8






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          38
          down vote













          Install x11vnc:



          sudo apt-get install x11vnc


          Create a password for your user:



          x11vnc -storepasswd


          If you have ssh setup you can use it to start x11vnc assuming you are logged in already, but remember to tell it to use your password file:



          x11vnc -usepw


          If you are not logged in you will get an error with the explanation:



          If NO ONE is logged into an X session yet, but there is a greeter login
          program like "gdm", "kdm", "xdm", or "dtlogin" running, you will need
          to find and use the raw display manager MIT-MAGIC-COOKIE file.
          Some examples for various display managers:

          gdm: -auth /var/gdm/:0.Xauth
          -auth /var/lib/gdm/:0.Xauth
          kdm: -auth /var/lib/kdm/A:0-crWk72
          -auth /var/run/xauth/A:0-crWk72
          xdm: -auth /var/lib/xdm/authdir/authfiles/A:0-XQvaJk
          dtlogin: -auth /var/dt/A:0-UgaaXa


          Assuming you are using lightdm for the login you can fix this problem you can start x11vnc with the command:



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


          I am not sure this is the best idea to run x11vnc as root. Maybe someone could edit with a way to access the login without using sudo.



          Once this is running you should be able to connect using a vnc client such as krdc (for KDE). You might want to use GNU Screen to keep x11vnc running without needing the ssh session open



          I was able to figure this out using http://ubuntuforums.org/showthread.php?t=2039022.



          Here is a sample upstart job you can use to make it run at startup. It needs to be put in /etc/init/x11vnc.conf. (Note that newer versions of Ubuntu use systemd so see the other answer that has a sample systemd config):



          # description "start and stop x11vnc"

          description "x11vnc"

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

          console log
          #chdir /home/
          #setuid 1000
          #setgid 1000

          respawn
          respawn limit 20 5

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


          Once you have made this file you can start it by running:
          sudo start x11vnc
          You can check the log at: /var/log/upstart/x11vnc.log






          share|improve this answer



















          • 1




            You can run x11vnc as a normal user, no problem. For example: ssh to the host and run x11vnc -safer -forever -display :0 2>&1 & in a tmux session (good practice), it'll run under $USER.
            – Terry Wang
            Jul 17 '13 at 5:43












          • Also, just for reference, in order to change the viewport: superuser.com/questions/270608/…
            – Wtower
            Dec 19 '14 at 9:25






          • 2




            This doesn't explain how to have it auto start as requested (and is a common requirement for such a feature)
            – LovesTha
            Feb 25 '15 at 21:39






          • 1




            See here for a full list of x11vnc options. It took me a long time to find this: karlrunge.com/x11vnc/x11vnc_opts.html
            – Gabriel Staples
            Sep 7 '16 at 1:55






          • 1




            And see here for an excellent tutorial on setting this up on a Raspberry Pi with auto-start at boot: megaleecher.net/Raspberry_Pi_VNC_Setup
            – Gabriel Staples
            Sep 7 '16 at 1:56















          up vote
          38
          down vote













          Install x11vnc:



          sudo apt-get install x11vnc


          Create a password for your user:



          x11vnc -storepasswd


          If you have ssh setup you can use it to start x11vnc assuming you are logged in already, but remember to tell it to use your password file:



          x11vnc -usepw


          If you are not logged in you will get an error with the explanation:



          If NO ONE is logged into an X session yet, but there is a greeter login
          program like "gdm", "kdm", "xdm", or "dtlogin" running, you will need
          to find and use the raw display manager MIT-MAGIC-COOKIE file.
          Some examples for various display managers:

          gdm: -auth /var/gdm/:0.Xauth
          -auth /var/lib/gdm/:0.Xauth
          kdm: -auth /var/lib/kdm/A:0-crWk72
          -auth /var/run/xauth/A:0-crWk72
          xdm: -auth /var/lib/xdm/authdir/authfiles/A:0-XQvaJk
          dtlogin: -auth /var/dt/A:0-UgaaXa


          Assuming you are using lightdm for the login you can fix this problem you can start x11vnc with the command:



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


          I am not sure this is the best idea to run x11vnc as root. Maybe someone could edit with a way to access the login without using sudo.



          Once this is running you should be able to connect using a vnc client such as krdc (for KDE). You might want to use GNU Screen to keep x11vnc running without needing the ssh session open



          I was able to figure this out using http://ubuntuforums.org/showthread.php?t=2039022.



          Here is a sample upstart job you can use to make it run at startup. It needs to be put in /etc/init/x11vnc.conf. (Note that newer versions of Ubuntu use systemd so see the other answer that has a sample systemd config):



          # description "start and stop x11vnc"

          description "x11vnc"

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

          console log
          #chdir /home/
          #setuid 1000
          #setgid 1000

          respawn
          respawn limit 20 5

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


          Once you have made this file you can start it by running:
          sudo start x11vnc
          You can check the log at: /var/log/upstart/x11vnc.log






          share|improve this answer



















          • 1




            You can run x11vnc as a normal user, no problem. For example: ssh to the host and run x11vnc -safer -forever -display :0 2>&1 & in a tmux session (good practice), it'll run under $USER.
            – Terry Wang
            Jul 17 '13 at 5:43












          • Also, just for reference, in order to change the viewport: superuser.com/questions/270608/…
            – Wtower
            Dec 19 '14 at 9:25






          • 2




            This doesn't explain how to have it auto start as requested (and is a common requirement for such a feature)
            – LovesTha
            Feb 25 '15 at 21:39






          • 1




            See here for a full list of x11vnc options. It took me a long time to find this: karlrunge.com/x11vnc/x11vnc_opts.html
            – Gabriel Staples
            Sep 7 '16 at 1:55






          • 1




            And see here for an excellent tutorial on setting this up on a Raspberry Pi with auto-start at boot: megaleecher.net/Raspberry_Pi_VNC_Setup
            – Gabriel Staples
            Sep 7 '16 at 1:56













          up vote
          38
          down vote










          up vote
          38
          down vote









          Install x11vnc:



          sudo apt-get install x11vnc


          Create a password for your user:



          x11vnc -storepasswd


          If you have ssh setup you can use it to start x11vnc assuming you are logged in already, but remember to tell it to use your password file:



          x11vnc -usepw


          If you are not logged in you will get an error with the explanation:



          If NO ONE is logged into an X session yet, but there is a greeter login
          program like "gdm", "kdm", "xdm", or "dtlogin" running, you will need
          to find and use the raw display manager MIT-MAGIC-COOKIE file.
          Some examples for various display managers:

          gdm: -auth /var/gdm/:0.Xauth
          -auth /var/lib/gdm/:0.Xauth
          kdm: -auth /var/lib/kdm/A:0-crWk72
          -auth /var/run/xauth/A:0-crWk72
          xdm: -auth /var/lib/xdm/authdir/authfiles/A:0-XQvaJk
          dtlogin: -auth /var/dt/A:0-UgaaXa


          Assuming you are using lightdm for the login you can fix this problem you can start x11vnc with the command:



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


          I am not sure this is the best idea to run x11vnc as root. Maybe someone could edit with a way to access the login without using sudo.



          Once this is running you should be able to connect using a vnc client such as krdc (for KDE). You might want to use GNU Screen to keep x11vnc running without needing the ssh session open



          I was able to figure this out using http://ubuntuforums.org/showthread.php?t=2039022.



          Here is a sample upstart job you can use to make it run at startup. It needs to be put in /etc/init/x11vnc.conf. (Note that newer versions of Ubuntu use systemd so see the other answer that has a sample systemd config):



          # description "start and stop x11vnc"

          description "x11vnc"

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

          console log
          #chdir /home/
          #setuid 1000
          #setgid 1000

          respawn
          respawn limit 20 5

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


          Once you have made this file you can start it by running:
          sudo start x11vnc
          You can check the log at: /var/log/upstart/x11vnc.log






          share|improve this answer














          Install x11vnc:



          sudo apt-get install x11vnc


          Create a password for your user:



          x11vnc -storepasswd


          If you have ssh setup you can use it to start x11vnc assuming you are logged in already, but remember to tell it to use your password file:



          x11vnc -usepw


          If you are not logged in you will get an error with the explanation:



          If NO ONE is logged into an X session yet, but there is a greeter login
          program like "gdm", "kdm", "xdm", or "dtlogin" running, you will need
          to find and use the raw display manager MIT-MAGIC-COOKIE file.
          Some examples for various display managers:

          gdm: -auth /var/gdm/:0.Xauth
          -auth /var/lib/gdm/:0.Xauth
          kdm: -auth /var/lib/kdm/A:0-crWk72
          -auth /var/run/xauth/A:0-crWk72
          xdm: -auth /var/lib/xdm/authdir/authfiles/A:0-XQvaJk
          dtlogin: -auth /var/dt/A:0-UgaaXa


          Assuming you are using lightdm for the login you can fix this problem you can start x11vnc with the command:



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


          I am not sure this is the best idea to run x11vnc as root. Maybe someone could edit with a way to access the login without using sudo.



          Once this is running you should be able to connect using a vnc client such as krdc (for KDE). You might want to use GNU Screen to keep x11vnc running without needing the ssh session open



          I was able to figure this out using http://ubuntuforums.org/showthread.php?t=2039022.



          Here is a sample upstart job you can use to make it run at startup. It needs to be put in /etc/init/x11vnc.conf. (Note that newer versions of Ubuntu use systemd so see the other answer that has a sample systemd config):



          # description "start and stop x11vnc"

          description "x11vnc"

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

          console log
          #chdir /home/
          #setuid 1000
          #setgid 1000

          respawn
          respawn limit 20 5

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


          Once you have made this file you can start it by running:
          sudo start x11vnc
          You can check the log at: /var/log/upstart/x11vnc.log







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jun 20 at 18:38

























          answered Mar 28 '13 at 15:42









          Allen

          536412




          536412








          • 1




            You can run x11vnc as a normal user, no problem. For example: ssh to the host and run x11vnc -safer -forever -display :0 2>&1 & in a tmux session (good practice), it'll run under $USER.
            – Terry Wang
            Jul 17 '13 at 5:43












          • Also, just for reference, in order to change the viewport: superuser.com/questions/270608/…
            – Wtower
            Dec 19 '14 at 9:25






          • 2




            This doesn't explain how to have it auto start as requested (and is a common requirement for such a feature)
            – LovesTha
            Feb 25 '15 at 21:39






          • 1




            See here for a full list of x11vnc options. It took me a long time to find this: karlrunge.com/x11vnc/x11vnc_opts.html
            – Gabriel Staples
            Sep 7 '16 at 1:55






          • 1




            And see here for an excellent tutorial on setting this up on a Raspberry Pi with auto-start at boot: megaleecher.net/Raspberry_Pi_VNC_Setup
            – Gabriel Staples
            Sep 7 '16 at 1:56














          • 1




            You can run x11vnc as a normal user, no problem. For example: ssh to the host and run x11vnc -safer -forever -display :0 2>&1 & in a tmux session (good practice), it'll run under $USER.
            – Terry Wang
            Jul 17 '13 at 5:43












          • Also, just for reference, in order to change the viewport: superuser.com/questions/270608/…
            – Wtower
            Dec 19 '14 at 9:25






          • 2




            This doesn't explain how to have it auto start as requested (and is a common requirement for such a feature)
            – LovesTha
            Feb 25 '15 at 21:39






          • 1




            See here for a full list of x11vnc options. It took me a long time to find this: karlrunge.com/x11vnc/x11vnc_opts.html
            – Gabriel Staples
            Sep 7 '16 at 1:55






          • 1




            And see here for an excellent tutorial on setting this up on a Raspberry Pi with auto-start at boot: megaleecher.net/Raspberry_Pi_VNC_Setup
            – Gabriel Staples
            Sep 7 '16 at 1:56








          1




          1




          You can run x11vnc as a normal user, no problem. For example: ssh to the host and run x11vnc -safer -forever -display :0 2>&1 & in a tmux session (good practice), it'll run under $USER.
          – Terry Wang
          Jul 17 '13 at 5:43






          You can run x11vnc as a normal user, no problem. For example: ssh to the host and run x11vnc -safer -forever -display :0 2>&1 & in a tmux session (good practice), it'll run under $USER.
          – Terry Wang
          Jul 17 '13 at 5:43














          Also, just for reference, in order to change the viewport: superuser.com/questions/270608/…
          – Wtower
          Dec 19 '14 at 9:25




          Also, just for reference, in order to change the viewport: superuser.com/questions/270608/…
          – Wtower
          Dec 19 '14 at 9:25




          2




          2




          This doesn't explain how to have it auto start as requested (and is a common requirement for such a feature)
          – LovesTha
          Feb 25 '15 at 21:39




          This doesn't explain how to have it auto start as requested (and is a common requirement for such a feature)
          – LovesTha
          Feb 25 '15 at 21:39




          1




          1




          See here for a full list of x11vnc options. It took me a long time to find this: karlrunge.com/x11vnc/x11vnc_opts.html
          – Gabriel Staples
          Sep 7 '16 at 1:55




          See here for a full list of x11vnc options. It took me a long time to find this: karlrunge.com/x11vnc/x11vnc_opts.html
          – Gabriel Staples
          Sep 7 '16 at 1:55




          1




          1




          And see here for an excellent tutorial on setting this up on a Raspberry Pi with auto-start at boot: megaleecher.net/Raspberry_Pi_VNC_Setup
          – Gabriel Staples
          Sep 7 '16 at 1:56




          And see here for an excellent tutorial on setting this up on a Raspberry Pi with auto-start at boot: megaleecher.net/Raspberry_Pi_VNC_Setup
          – Gabriel Staples
          Sep 7 '16 at 1:56












          up vote
          33
          down vote













          The above answers solve the problem, though a couple of amendments for versions of Ubuntu with systemd (15.04+), as follows:




          • Take advantage of new -auth guess functionality in x11vnc - which helps!

          • Update for systemd (not upstart)


          Run the following to install:



          sudo apt-get install x11vnc
          sudo x11vnc -storepasswd yourVNCpasswordHERE /etc/x11vnc.pass
          # for Ubuntu 15.04+
          sudo nano /lib/systemd/system/x11vnc.service
          # for Ubuntu 16.10+
          sudo nano /etc/systemd/system/x11vnc.service


          Insert this into the file:



          [Unit]
          Description="x11vnc"
          Requires=display-manager.service
          After=display-manager.service

          [Service]
          ExecStart=/usr/bin/x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :0 -auth guess -rfbauth /etc/x11vnc.pass
          ExecStop=/usr/bin/killall x11vnc
          Restart=on-failure
          Restart-sec=2

          [Install]
          WantedBy=multi-user.target


          Then, start with:



          sudo systemctl daemon-reload
          sudo systemctl start x11vnc


          And ensure the service starts on boot:



          sudo systemctl enable x11vnc





          share|improve this answer























          • Referenced bbs.archlinux.org/viewtopic.php?id=168756 for some advice on Requires/Afters params
            – babelmonk
            Sep 22 '15 at 9:48






          • 2




            why isn't this answer marked as the correct answer?
            – Cybex
            Jan 2 '17 at 11:19






          • 1




            If there is no display at all, then one may want to set arbitrary resolution: sudo xrandr --fb 1920x1080.
            – Orient
            Jul 26 '17 at 7:55






          • 2




            It is not a given the x11vnc will work immediately. It would be a good idea to provide a testing command before commiting to a service that restarts on failure every 2 seconds. I'm using lightdm and xfce4 on a headless cloud Ubuntu 17.10 server. Restart-sec should be RestartSec
            – Ray Foss
            Dec 21 '17 at 17:45








          • 1




            Ubuntu 18.04 also seems to want RestartSec rather than Restart-sec.
            – Scott Willeke
            Jul 7 at 15:48















          up vote
          33
          down vote













          The above answers solve the problem, though a couple of amendments for versions of Ubuntu with systemd (15.04+), as follows:




          • Take advantage of new -auth guess functionality in x11vnc - which helps!

          • Update for systemd (not upstart)


          Run the following to install:



          sudo apt-get install x11vnc
          sudo x11vnc -storepasswd yourVNCpasswordHERE /etc/x11vnc.pass
          # for Ubuntu 15.04+
          sudo nano /lib/systemd/system/x11vnc.service
          # for Ubuntu 16.10+
          sudo nano /etc/systemd/system/x11vnc.service


          Insert this into the file:



          [Unit]
          Description="x11vnc"
          Requires=display-manager.service
          After=display-manager.service

          [Service]
          ExecStart=/usr/bin/x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :0 -auth guess -rfbauth /etc/x11vnc.pass
          ExecStop=/usr/bin/killall x11vnc
          Restart=on-failure
          Restart-sec=2

          [Install]
          WantedBy=multi-user.target


          Then, start with:



          sudo systemctl daemon-reload
          sudo systemctl start x11vnc


          And ensure the service starts on boot:



          sudo systemctl enable x11vnc





          share|improve this answer























          • Referenced bbs.archlinux.org/viewtopic.php?id=168756 for some advice on Requires/Afters params
            – babelmonk
            Sep 22 '15 at 9:48






          • 2




            why isn't this answer marked as the correct answer?
            – Cybex
            Jan 2 '17 at 11:19






          • 1




            If there is no display at all, then one may want to set arbitrary resolution: sudo xrandr --fb 1920x1080.
            – Orient
            Jul 26 '17 at 7:55






          • 2




            It is not a given the x11vnc will work immediately. It would be a good idea to provide a testing command before commiting to a service that restarts on failure every 2 seconds. I'm using lightdm and xfce4 on a headless cloud Ubuntu 17.10 server. Restart-sec should be RestartSec
            – Ray Foss
            Dec 21 '17 at 17:45








          • 1




            Ubuntu 18.04 also seems to want RestartSec rather than Restart-sec.
            – Scott Willeke
            Jul 7 at 15:48













          up vote
          33
          down vote










          up vote
          33
          down vote









          The above answers solve the problem, though a couple of amendments for versions of Ubuntu with systemd (15.04+), as follows:




          • Take advantage of new -auth guess functionality in x11vnc - which helps!

          • Update for systemd (not upstart)


          Run the following to install:



          sudo apt-get install x11vnc
          sudo x11vnc -storepasswd yourVNCpasswordHERE /etc/x11vnc.pass
          # for Ubuntu 15.04+
          sudo nano /lib/systemd/system/x11vnc.service
          # for Ubuntu 16.10+
          sudo nano /etc/systemd/system/x11vnc.service


          Insert this into the file:



          [Unit]
          Description="x11vnc"
          Requires=display-manager.service
          After=display-manager.service

          [Service]
          ExecStart=/usr/bin/x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :0 -auth guess -rfbauth /etc/x11vnc.pass
          ExecStop=/usr/bin/killall x11vnc
          Restart=on-failure
          Restart-sec=2

          [Install]
          WantedBy=multi-user.target


          Then, start with:



          sudo systemctl daemon-reload
          sudo systemctl start x11vnc


          And ensure the service starts on boot:



          sudo systemctl enable x11vnc





          share|improve this answer














          The above answers solve the problem, though a couple of amendments for versions of Ubuntu with systemd (15.04+), as follows:




          • Take advantage of new -auth guess functionality in x11vnc - which helps!

          • Update for systemd (not upstart)


          Run the following to install:



          sudo apt-get install x11vnc
          sudo x11vnc -storepasswd yourVNCpasswordHERE /etc/x11vnc.pass
          # for Ubuntu 15.04+
          sudo nano /lib/systemd/system/x11vnc.service
          # for Ubuntu 16.10+
          sudo nano /etc/systemd/system/x11vnc.service


          Insert this into the file:



          [Unit]
          Description="x11vnc"
          Requires=display-manager.service
          After=display-manager.service

          [Service]
          ExecStart=/usr/bin/x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :0 -auth guess -rfbauth /etc/x11vnc.pass
          ExecStop=/usr/bin/killall x11vnc
          Restart=on-failure
          Restart-sec=2

          [Install]
          WantedBy=multi-user.target


          Then, start with:



          sudo systemctl daemon-reload
          sudo systemctl start x11vnc


          And ensure the service starts on boot:



          sudo systemctl enable x11vnc






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 3 '17 at 13:42

























          answered Sep 22 '15 at 9:17









          babelmonk

          51955




          51955












          • Referenced bbs.archlinux.org/viewtopic.php?id=168756 for some advice on Requires/Afters params
            – babelmonk
            Sep 22 '15 at 9:48






          • 2




            why isn't this answer marked as the correct answer?
            – Cybex
            Jan 2 '17 at 11:19






          • 1




            If there is no display at all, then one may want to set arbitrary resolution: sudo xrandr --fb 1920x1080.
            – Orient
            Jul 26 '17 at 7:55






          • 2




            It is not a given the x11vnc will work immediately. It would be a good idea to provide a testing command before commiting to a service that restarts on failure every 2 seconds. I'm using lightdm and xfce4 on a headless cloud Ubuntu 17.10 server. Restart-sec should be RestartSec
            – Ray Foss
            Dec 21 '17 at 17:45








          • 1




            Ubuntu 18.04 also seems to want RestartSec rather than Restart-sec.
            – Scott Willeke
            Jul 7 at 15:48


















          • Referenced bbs.archlinux.org/viewtopic.php?id=168756 for some advice on Requires/Afters params
            – babelmonk
            Sep 22 '15 at 9:48






          • 2




            why isn't this answer marked as the correct answer?
            – Cybex
            Jan 2 '17 at 11:19






          • 1




            If there is no display at all, then one may want to set arbitrary resolution: sudo xrandr --fb 1920x1080.
            – Orient
            Jul 26 '17 at 7:55






          • 2




            It is not a given the x11vnc will work immediately. It would be a good idea to provide a testing command before commiting to a service that restarts on failure every 2 seconds. I'm using lightdm and xfce4 on a headless cloud Ubuntu 17.10 server. Restart-sec should be RestartSec
            – Ray Foss
            Dec 21 '17 at 17:45








          • 1




            Ubuntu 18.04 also seems to want RestartSec rather than Restart-sec.
            – Scott Willeke
            Jul 7 at 15:48
















          Referenced bbs.archlinux.org/viewtopic.php?id=168756 for some advice on Requires/Afters params
          – babelmonk
          Sep 22 '15 at 9:48




          Referenced bbs.archlinux.org/viewtopic.php?id=168756 for some advice on Requires/Afters params
          – babelmonk
          Sep 22 '15 at 9:48




          2




          2




          why isn't this answer marked as the correct answer?
          – Cybex
          Jan 2 '17 at 11:19




          why isn't this answer marked as the correct answer?
          – Cybex
          Jan 2 '17 at 11:19




          1




          1




          If there is no display at all, then one may want to set arbitrary resolution: sudo xrandr --fb 1920x1080.
          – Orient
          Jul 26 '17 at 7:55




          If there is no display at all, then one may want to set arbitrary resolution: sudo xrandr --fb 1920x1080.
          – Orient
          Jul 26 '17 at 7:55




          2




          2




          It is not a given the x11vnc will work immediately. It would be a good idea to provide a testing command before commiting to a service that restarts on failure every 2 seconds. I'm using lightdm and xfce4 on a headless cloud Ubuntu 17.10 server. Restart-sec should be RestartSec
          – Ray Foss
          Dec 21 '17 at 17:45






          It is not a given the x11vnc will work immediately. It would be a good idea to provide a testing command before commiting to a service that restarts on failure every 2 seconds. I'm using lightdm and xfce4 on a headless cloud Ubuntu 17.10 server. Restart-sec should be RestartSec
          – Ray Foss
          Dec 21 '17 at 17:45






          1




          1




          Ubuntu 18.04 also seems to want RestartSec rather than Restart-sec.
          – Scott Willeke
          Jul 7 at 15:48




          Ubuntu 18.04 also seems to want RestartSec rather than Restart-sec.
          – Scott Willeke
          Jul 7 at 15:48










          up vote
          14
          down vote













          Here's how:





          1. Install the X11VNC server (or through Ubuntu
            Software Center -> X11VNC Server)



            sudo apt-get install x11vnc



          2. Create a VNC password file.



            sudo x11vnc -storepasswd yourVNCpasswordHERE /etc/x11vnc.pass



          3. Create a job file in the editor nano (or gedit, leafpad etc.).



            sudo nano /etc/init/x11vnc.conf



          4. Paste this into the file:



            start on login-session-start

            script

            /usr/bin/x11vnc -xkb -forever -auth /var/run/lightdm/root/:0 -display :0 -rfbauth /etc/x11vnc.pass -rfbport 5900 -bg -o /var/log/x11vnc.log

            end script


          5. Save the file. You created a job for the Upstart event login-session-start.


          6. Restart Ubuntu.


          That's it! You should now be able to connect with any VNC client even before login.






          share|improve this answer























          • But how do you get it to work when lightdm doesn't create the auth file till a monitor is connected?
            – LovesTha
            Feb 25 '15 at 21:37










          • @didibus I've been trying to do this in Lubuntu, but x11vnc fails to autostart every time. It won't even start as a service, for that matter. File syntax is correct and I can start x11vnc from the shell just fine. What am I missing?
            – linuxgringo
            Jun 21 '15 at 14:10










          • This works on Lubuntu too. Specifically, LeMaker's version of Lubuntu for the Banana Pi.
            – AaronD
            Mar 1 '16 at 21:05















          up vote
          14
          down vote













          Here's how:





          1. Install the X11VNC server (or through Ubuntu
            Software Center -> X11VNC Server)



            sudo apt-get install x11vnc



          2. Create a VNC password file.



            sudo x11vnc -storepasswd yourVNCpasswordHERE /etc/x11vnc.pass



          3. Create a job file in the editor nano (or gedit, leafpad etc.).



            sudo nano /etc/init/x11vnc.conf



          4. Paste this into the file:



            start on login-session-start

            script

            /usr/bin/x11vnc -xkb -forever -auth /var/run/lightdm/root/:0 -display :0 -rfbauth /etc/x11vnc.pass -rfbport 5900 -bg -o /var/log/x11vnc.log

            end script


          5. Save the file. You created a job for the Upstart event login-session-start.


          6. Restart Ubuntu.


          That's it! You should now be able to connect with any VNC client even before login.






          share|improve this answer























          • But how do you get it to work when lightdm doesn't create the auth file till a monitor is connected?
            – LovesTha
            Feb 25 '15 at 21:37










          • @didibus I've been trying to do this in Lubuntu, but x11vnc fails to autostart every time. It won't even start as a service, for that matter. File syntax is correct and I can start x11vnc from the shell just fine. What am I missing?
            – linuxgringo
            Jun 21 '15 at 14:10










          • This works on Lubuntu too. Specifically, LeMaker's version of Lubuntu for the Banana Pi.
            – AaronD
            Mar 1 '16 at 21:05













          up vote
          14
          down vote










          up vote
          14
          down vote









          Here's how:





          1. Install the X11VNC server (or through Ubuntu
            Software Center -> X11VNC Server)



            sudo apt-get install x11vnc



          2. Create a VNC password file.



            sudo x11vnc -storepasswd yourVNCpasswordHERE /etc/x11vnc.pass



          3. Create a job file in the editor nano (or gedit, leafpad etc.).



            sudo nano /etc/init/x11vnc.conf



          4. Paste this into the file:



            start on login-session-start

            script

            /usr/bin/x11vnc -xkb -forever -auth /var/run/lightdm/root/:0 -display :0 -rfbauth /etc/x11vnc.pass -rfbport 5900 -bg -o /var/log/x11vnc.log

            end script


          5. Save the file. You created a job for the Upstart event login-session-start.


          6. Restart Ubuntu.


          That's it! You should now be able to connect with any VNC client even before login.






          share|improve this answer














          Here's how:





          1. Install the X11VNC server (or through Ubuntu
            Software Center -> X11VNC Server)



            sudo apt-get install x11vnc



          2. Create a VNC password file.



            sudo x11vnc -storepasswd yourVNCpasswordHERE /etc/x11vnc.pass



          3. Create a job file in the editor nano (or gedit, leafpad etc.).



            sudo nano /etc/init/x11vnc.conf



          4. Paste this into the file:



            start on login-session-start

            script

            /usr/bin/x11vnc -xkb -forever -auth /var/run/lightdm/root/:0 -display :0 -rfbauth /etc/x11vnc.pass -rfbport 5900 -bg -o /var/log/x11vnc.log

            end script


          5. Save the file. You created a job for the Upstart event login-session-start.


          6. Restart Ubuntu.


          That's it! You should now be able to connect with any VNC client even before login.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 31 '16 at 14:42









          Draco Ater

          31128




          31128










          answered Sep 25 '14 at 18:33









          Didier A.

          25426




          25426












          • But how do you get it to work when lightdm doesn't create the auth file till a monitor is connected?
            – LovesTha
            Feb 25 '15 at 21:37










          • @didibus I've been trying to do this in Lubuntu, but x11vnc fails to autostart every time. It won't even start as a service, for that matter. File syntax is correct and I can start x11vnc from the shell just fine. What am I missing?
            – linuxgringo
            Jun 21 '15 at 14:10










          • This works on Lubuntu too. Specifically, LeMaker's version of Lubuntu for the Banana Pi.
            – AaronD
            Mar 1 '16 at 21:05


















          • But how do you get it to work when lightdm doesn't create the auth file till a monitor is connected?
            – LovesTha
            Feb 25 '15 at 21:37










          • @didibus I've been trying to do this in Lubuntu, but x11vnc fails to autostart every time. It won't even start as a service, for that matter. File syntax is correct and I can start x11vnc from the shell just fine. What am I missing?
            – linuxgringo
            Jun 21 '15 at 14:10










          • This works on Lubuntu too. Specifically, LeMaker's version of Lubuntu for the Banana Pi.
            – AaronD
            Mar 1 '16 at 21:05
















          But how do you get it to work when lightdm doesn't create the auth file till a monitor is connected?
          – LovesTha
          Feb 25 '15 at 21:37




          But how do you get it to work when lightdm doesn't create the auth file till a monitor is connected?
          – LovesTha
          Feb 25 '15 at 21:37












          @didibus I've been trying to do this in Lubuntu, but x11vnc fails to autostart every time. It won't even start as a service, for that matter. File syntax is correct and I can start x11vnc from the shell just fine. What am I missing?
          – linuxgringo
          Jun 21 '15 at 14:10




          @didibus I've been trying to do this in Lubuntu, but x11vnc fails to autostart every time. It won't even start as a service, for that matter. File syntax is correct and I can start x11vnc from the shell just fine. What am I missing?
          – linuxgringo
          Jun 21 '15 at 14:10












          This works on Lubuntu too. Specifically, LeMaker's version of Lubuntu for the Banana Pi.
          – AaronD
          Mar 1 '16 at 21:05




          This works on Lubuntu too. Specifically, LeMaker's version of Lubuntu for the Banana Pi.
          – AaronD
          Mar 1 '16 at 21:05










          up vote
          2
          down vote













          babelmonks answer as a bash script, copy and save as x11vnc.sh & run with sudo bash /path/to/file/x11vnc.sh (sorry dont have enough rep to post a comment)



          #!/bin/bash
          #install x11vnc & set password
          apt-get install x11vnc -y
          x11vnc -storepasswd 123456 /etc/x11vnc.pass
          #create config file for system service
          cat > /lib/systemd/system/x11vnc.service <<-EOF
          [Unit]
          Description="x11vnc"
          Requires=display-manager.service
          After=display-manager.service

          [Service]
          ExecStart=/usr/bin/x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :0 -auth guess -rfbauth /etc/x11vnc.pass
          ExecStop=/usr/bin/killall x11vnc

          [Install]
          WantedBy=multi-user.target
          EOF
          #restart new services & enable on boot
          systemctl daemon-reload
          systemctl start x11vnc
          systemctl enable x11vnc





          share|improve this answer





















          • If you want to improve another answer, please suggest an edit to it and don't create a new answer.
            – David Foerster
            Jan 3 '16 at 9:31










          • Will happily add this to mine if you'd like to create an edit @nix-badweasel
            – babelmonk
            Jan 3 '17 at 13:36

















          up vote
          2
          down vote













          babelmonks answer as a bash script, copy and save as x11vnc.sh & run with sudo bash /path/to/file/x11vnc.sh (sorry dont have enough rep to post a comment)



          #!/bin/bash
          #install x11vnc & set password
          apt-get install x11vnc -y
          x11vnc -storepasswd 123456 /etc/x11vnc.pass
          #create config file for system service
          cat > /lib/systemd/system/x11vnc.service <<-EOF
          [Unit]
          Description="x11vnc"
          Requires=display-manager.service
          After=display-manager.service

          [Service]
          ExecStart=/usr/bin/x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :0 -auth guess -rfbauth /etc/x11vnc.pass
          ExecStop=/usr/bin/killall x11vnc

          [Install]
          WantedBy=multi-user.target
          EOF
          #restart new services & enable on boot
          systemctl daemon-reload
          systemctl start x11vnc
          systemctl enable x11vnc





          share|improve this answer





















          • If you want to improve another answer, please suggest an edit to it and don't create a new answer.
            – David Foerster
            Jan 3 '16 at 9:31










          • Will happily add this to mine if you'd like to create an edit @nix-badweasel
            – babelmonk
            Jan 3 '17 at 13:36















          up vote
          2
          down vote










          up vote
          2
          down vote









          babelmonks answer as a bash script, copy and save as x11vnc.sh & run with sudo bash /path/to/file/x11vnc.sh (sorry dont have enough rep to post a comment)



          #!/bin/bash
          #install x11vnc & set password
          apt-get install x11vnc -y
          x11vnc -storepasswd 123456 /etc/x11vnc.pass
          #create config file for system service
          cat > /lib/systemd/system/x11vnc.service <<-EOF
          [Unit]
          Description="x11vnc"
          Requires=display-manager.service
          After=display-manager.service

          [Service]
          ExecStart=/usr/bin/x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :0 -auth guess -rfbauth /etc/x11vnc.pass
          ExecStop=/usr/bin/killall x11vnc

          [Install]
          WantedBy=multi-user.target
          EOF
          #restart new services & enable on boot
          systemctl daemon-reload
          systemctl start x11vnc
          systemctl enable x11vnc





          share|improve this answer












          babelmonks answer as a bash script, copy and save as x11vnc.sh & run with sudo bash /path/to/file/x11vnc.sh (sorry dont have enough rep to post a comment)



          #!/bin/bash
          #install x11vnc & set password
          apt-get install x11vnc -y
          x11vnc -storepasswd 123456 /etc/x11vnc.pass
          #create config file for system service
          cat > /lib/systemd/system/x11vnc.service <<-EOF
          [Unit]
          Description="x11vnc"
          Requires=display-manager.service
          After=display-manager.service

          [Service]
          ExecStart=/usr/bin/x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :0 -auth guess -rfbauth /etc/x11vnc.pass
          ExecStop=/usr/bin/killall x11vnc

          [Install]
          WantedBy=multi-user.target
          EOF
          #restart new services & enable on boot
          systemctl daemon-reload
          systemctl start x11vnc
          systemctl enable x11vnc






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 2 '16 at 23:26









          Nix Badweasel

          212




          212












          • If you want to improve another answer, please suggest an edit to it and don't create a new answer.
            – David Foerster
            Jan 3 '16 at 9:31










          • Will happily add this to mine if you'd like to create an edit @nix-badweasel
            – babelmonk
            Jan 3 '17 at 13:36




















          • If you want to improve another answer, please suggest an edit to it and don't create a new answer.
            – David Foerster
            Jan 3 '16 at 9:31










          • Will happily add this to mine if you'd like to create an edit @nix-badweasel
            – babelmonk
            Jan 3 '17 at 13:36


















          If you want to improve another answer, please suggest an edit to it and don't create a new answer.
          – David Foerster
          Jan 3 '16 at 9:31




          If you want to improve another answer, please suggest an edit to it and don't create a new answer.
          – David Foerster
          Jan 3 '16 at 9:31












          Will happily add this to mine if you'd like to create an edit @nix-badweasel
          – babelmonk
          Jan 3 '17 at 13:36






          Will happily add this to mine if you'd like to create an edit @nix-badweasel
          – babelmonk
          Jan 3 '17 at 13:36












          up vote
          1
          down vote













          Use my script for easy set up: installvncubuntu1604.sh



          Usage:



          chmod +x ./installvncubuntu1604.sh; sudo ./installvncubuntu1604.sh





          share|improve this answer



























            up vote
            1
            down vote













            Use my script for easy set up: installvncubuntu1604.sh



            Usage:



            chmod +x ./installvncubuntu1604.sh; sudo ./installvncubuntu1604.sh





            share|improve this answer

























              up vote
              1
              down vote










              up vote
              1
              down vote









              Use my script for easy set up: installvncubuntu1604.sh



              Usage:



              chmod +x ./installvncubuntu1604.sh; sudo ./installvncubuntu1604.sh





              share|improve this answer














              Use my script for easy set up: installvncubuntu1604.sh



              Usage:



              chmod +x ./installvncubuntu1604.sh; sudo ./installvncubuntu1604.sh






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Jul 25 '17 at 10:17









              Adam Ryczkowski

              2,37752153




              2,37752153










              answered Mar 14 '17 at 16:20









              user665310

              111




              111






















                  up vote
                  1
                  down vote













                  Here is a config works for sddm (for KDE 5). Currently, -auth guess does not work for sddm, the auth file is different every time, so we need something like -auth /var/run/sddm/*.
                  The service looks like,



                  [Unit]
                  Description="x11vnc"
                  After=multi-user.target

                  [Service]
                  ExecStart=/bin/sh -c "/usr/bin/x11vnc -xkb -noxrecord -display :0 -auth /var/run/sddm/* -rfbauth /etc/x11vnc.pass"
                  ExecStop=/usr/bin/killall x11vnc

                  [Install]
                  WantedBy=multi-user.target


                  I have to put it after multi-user.target, if after display-manager.service, x11vnc cannot find auth file, maybe sddm generates auth file later. This is tested on Manjaro 18.






                  share|improve this answer

























                    up vote
                    1
                    down vote













                    Here is a config works for sddm (for KDE 5). Currently, -auth guess does not work for sddm, the auth file is different every time, so we need something like -auth /var/run/sddm/*.
                    The service looks like,



                    [Unit]
                    Description="x11vnc"
                    After=multi-user.target

                    [Service]
                    ExecStart=/bin/sh -c "/usr/bin/x11vnc -xkb -noxrecord -display :0 -auth /var/run/sddm/* -rfbauth /etc/x11vnc.pass"
                    ExecStop=/usr/bin/killall x11vnc

                    [Install]
                    WantedBy=multi-user.target


                    I have to put it after multi-user.target, if after display-manager.service, x11vnc cannot find auth file, maybe sddm generates auth file later. This is tested on Manjaro 18.






                    share|improve this answer























                      up vote
                      1
                      down vote










                      up vote
                      1
                      down vote









                      Here is a config works for sddm (for KDE 5). Currently, -auth guess does not work for sddm, the auth file is different every time, so we need something like -auth /var/run/sddm/*.
                      The service looks like,



                      [Unit]
                      Description="x11vnc"
                      After=multi-user.target

                      [Service]
                      ExecStart=/bin/sh -c "/usr/bin/x11vnc -xkb -noxrecord -display :0 -auth /var/run/sddm/* -rfbauth /etc/x11vnc.pass"
                      ExecStop=/usr/bin/killall x11vnc

                      [Install]
                      WantedBy=multi-user.target


                      I have to put it after multi-user.target, if after display-manager.service, x11vnc cannot find auth file, maybe sddm generates auth file later. This is tested on Manjaro 18.






                      share|improve this answer












                      Here is a config works for sddm (for KDE 5). Currently, -auth guess does not work for sddm, the auth file is different every time, so we need something like -auth /var/run/sddm/*.
                      The service looks like,



                      [Unit]
                      Description="x11vnc"
                      After=multi-user.target

                      [Service]
                      ExecStart=/bin/sh -c "/usr/bin/x11vnc -xkb -noxrecord -display :0 -auth /var/run/sddm/* -rfbauth /etc/x11vnc.pass"
                      ExecStop=/usr/bin/killall x11vnc

                      [Install]
                      WantedBy=multi-user.target


                      I have to put it after multi-user.target, if after display-manager.service, x11vnc cannot find auth file, maybe sddm generates auth file later. This is tested on Manjaro 18.







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Dec 2 at 21:38









                      sudoer

                      111




                      111






















                          up vote
                          0
                          down vote













                          I use my own shell: https://github.com/dvdvideo1234/UbuntuBatches/tree/master/x11VNC



                          start on login-session-start

                          script

                          sudo /usr/bin/x11vnc -xkb -auth /var/run/lightdm/root/:0 -noxrecord -noxfixes -noxdamage -rfbauth /var/srv/x11vnc/x11vnc.pass -forever -bg -rfbport <your_port> -o /var/srv/x11vnc/x11vnc.log

                          end script


                          into the file:



                          /etc/init/x11vnc.conf


                          It makes it auto-start on boot, even on the logon screen it asks for a password.






                          share|improve this answer



























                            up vote
                            0
                            down vote













                            I use my own shell: https://github.com/dvdvideo1234/UbuntuBatches/tree/master/x11VNC



                            start on login-session-start

                            script

                            sudo /usr/bin/x11vnc -xkb -auth /var/run/lightdm/root/:0 -noxrecord -noxfixes -noxdamage -rfbauth /var/srv/x11vnc/x11vnc.pass -forever -bg -rfbport <your_port> -o /var/srv/x11vnc/x11vnc.log

                            end script


                            into the file:



                            /etc/init/x11vnc.conf


                            It makes it auto-start on boot, even on the logon screen it asks for a password.






                            share|improve this answer

























                              up vote
                              0
                              down vote










                              up vote
                              0
                              down vote









                              I use my own shell: https://github.com/dvdvideo1234/UbuntuBatches/tree/master/x11VNC



                              start on login-session-start

                              script

                              sudo /usr/bin/x11vnc -xkb -auth /var/run/lightdm/root/:0 -noxrecord -noxfixes -noxdamage -rfbauth /var/srv/x11vnc/x11vnc.pass -forever -bg -rfbport <your_port> -o /var/srv/x11vnc/x11vnc.log

                              end script


                              into the file:



                              /etc/init/x11vnc.conf


                              It makes it auto-start on boot, even on the logon screen it asks for a password.






                              share|improve this answer














                              I use my own shell: https://github.com/dvdvideo1234/UbuntuBatches/tree/master/x11VNC



                              start on login-session-start

                              script

                              sudo /usr/bin/x11vnc -xkb -auth /var/run/lightdm/root/:0 -noxrecord -noxfixes -noxdamage -rfbauth /var/srv/x11vnc/x11vnc.pass -forever -bg -rfbport <your_port> -o /var/srv/x11vnc/x11vnc.log

                              end script


                              into the file:



                              /etc/init/x11vnc.conf


                              It makes it auto-start on boot, even on the logon screen it asks for a password.







                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited Mar 12 '16 at 14:54

























                              answered Mar 12 '16 at 9:04









                              Деян Добромиров

                              11618




                              11618






















                                  up vote
                                  0
                                  down vote













                                  Install x11vnc package



                                  #sudo apt-get install x11vnc


                                  Then set the password



                                  #x11vnc -usepw


                                  Then create startup script for x11vnc



                                  #sudo nano /etc/x11vnc.sh


                                  In File:



                                  /usr/bin/x11vnc -bg -forever -shared -reopen -usepw


                                  Then save



                                  #sudo chmod 777 /etc/x11vnc.sh


                                  Then add the script file to Control Center=>Startup Application
                                  Then Click Add



                                  > Name-----------x11vnc


                                  > Command-----<map the script file



                                  > Comment------service


                                  This is must be required to add for all user



                                  This will run after user login only






                                  share|improve this answer

























                                    up vote
                                    0
                                    down vote













                                    Install x11vnc package



                                    #sudo apt-get install x11vnc


                                    Then set the password



                                    #x11vnc -usepw


                                    Then create startup script for x11vnc



                                    #sudo nano /etc/x11vnc.sh


                                    In File:



                                    /usr/bin/x11vnc -bg -forever -shared -reopen -usepw


                                    Then save



                                    #sudo chmod 777 /etc/x11vnc.sh


                                    Then add the script file to Control Center=>Startup Application
                                    Then Click Add



                                    > Name-----------x11vnc


                                    > Command-----<map the script file



                                    > Comment------service


                                    This is must be required to add for all user



                                    This will run after user login only






                                    share|improve this answer























                                      up vote
                                      0
                                      down vote










                                      up vote
                                      0
                                      down vote









                                      Install x11vnc package



                                      #sudo apt-get install x11vnc


                                      Then set the password



                                      #x11vnc -usepw


                                      Then create startup script for x11vnc



                                      #sudo nano /etc/x11vnc.sh


                                      In File:



                                      /usr/bin/x11vnc -bg -forever -shared -reopen -usepw


                                      Then save



                                      #sudo chmod 777 /etc/x11vnc.sh


                                      Then add the script file to Control Center=>Startup Application
                                      Then Click Add



                                      > Name-----------x11vnc


                                      > Command-----<map the script file



                                      > Comment------service


                                      This is must be required to add for all user



                                      This will run after user login only






                                      share|improve this answer












                                      Install x11vnc package



                                      #sudo apt-get install x11vnc


                                      Then set the password



                                      #x11vnc -usepw


                                      Then create startup script for x11vnc



                                      #sudo nano /etc/x11vnc.sh


                                      In File:



                                      /usr/bin/x11vnc -bg -forever -shared -reopen -usepw


                                      Then save



                                      #sudo chmod 777 /etc/x11vnc.sh


                                      Then add the script file to Control Center=>Startup Application
                                      Then Click Add



                                      > Name-----------x11vnc


                                      > Command-----<map the script file



                                      > Comment------service


                                      This is must be required to add for all user



                                      This will run after user login only







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Aug 23 '17 at 12:24









                                      Nandhakumar M

                                      1




                                      1






























                                          draft saved

                                          draft discarded




















































                                          Thanks for contributing an answer to Ask Ubuntu!


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid



                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.


                                          To learn more, see our tips on writing great answers.





                                          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                          Please pay close attention to the following guidance:


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid



                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.


                                          To learn more, see our tips on writing great answers.




                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function () {
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f229989%2fhow-to-setup-x11vnc-to-access-with-graphical-login-screen%23new-answer', 'question_page');
                                          }
                                          );

                                          Post as a guest















                                          Required, but never shown





















































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown

































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown







                                          Popular posts from this blog

                                          Quarter-circle Tiles

                                          build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

                                          Mont Emei