3) Installing And Configuring x11vnc On Debian 9
Open up synaptic package manager and type x11vnc into the search box. Install the package and its recommended dependencies. Logout and restart your Debian machine. See image below:
After your Debian machine restarts open a terminal and type: x11vnc -storepasswd and hit Enter.
You will be prompted with Enter VNC password: where you enter a password.
You will be prompted again with Verify password: where you enter the same password again to verify it.
The next prompt will ask: Write password to /home/yourusername/.vnc/passwd? [y]/n to which you should type y and hit Enter.
The next prompt should read: Password written to: /home/yourusername/.vnc/passwd
Exit the terminal. You now have an x11vnc password.
I’m going to discuss briefly a simple, convenient, and secure way to configure x11vnc with Debian, which can also be applied in Linux Lite. It can be configured to autostart at login in the application autostart folder which I think is a waste of time since I am going to use an SSH tunnel connection anyway. Why start the server before you really need it? This is often considered desirable when running headless, but again unnecessary, and I also think it is undesirable to run it without an SSH tunnel or some other type of secure connection. It can be configured to start and run as a systemd service, but again another unnecessary and actually undesirable option unless you intend to secure it by some other means than an SSH tunnel. In any case the simplest and most convenient way to securely start and stop the server is via SSH, and to simplify it even more I’m going to write a BASH script with the options I know already work in the script to start x11vnc, and alias it in my .bashrc file. This adds the advantage of being able to simply open a text editor to change the x11vnc settings. Because I am going to use the Remmina client to start and stop the server with SSH even the x11vnc password is exchanged encrypted and not in clear text. For new Linux users this is really the simplest best way to deal with x11vnc in a secure method, whether setting it up on Linux Lite or Debian as the case may be.
First open up file manager on your Debian machine and right click on a blank space in your home folder and select new folder from the menu that appears. See image below:
I named my folder rdv1. You can use any folder name you like – just don’t start the folder name with x11vnc. Doing so can mess up x11vnc in Debian.
Next open up your text editor g-edit if you are running gnome Debian. Paste or type the command exactly how it is written here below replacing “yourusername” with your actual user name.
x11vnc -auth guess -once -loop -noxdamage -repeat -rfbauth /home/yourusername/.vnc/passwd -rfbport 5900 -shared
The x11vnc server options are set by the terms preceded with - . Always leave a space before a – in the script but not after. This script will run and work well the first time on any Debian 9 or Linux Lite machine with a Core2 Duo or newer Intel CPU, or an AthlonII 64bit or newer AMD CPU and 4gigs of RAM. I have saved the file as virdsk1.sh in /home/trinidad/rdv1/. Again avoid using x11vnc in the file name and save it in the folder you just created as a .sh file. In Debian 9 the usual #! in the first line of the script is not necessary; x11vnc is kind of its own #! anyway, like an extra x-server with an abstraction of salvage and connection tools on top. See images below:
If you have previously installed dconf-editor like me, and set nautilus to allow execution of scripts your script will probably show up in your file manager as executable already just because you saved it with a .sh file extension. Logout and login again and check it. Open up /home/yourusername/yourfoldername/ in my case /home/trinidad/rdv1/ and right click on the file and select properties from the menu that appears. When the properties window opens change your group user name access to read and write, and check the allow executing file as program box. Giving read/write to your user name group will allow you to edit the file from an SSH terminal if you want to without needing VNC, logged in as your user name. If your script cannot be made executable from nautilus use the command that follows here from root, su to root terminal first then: chmod +x /home/yourusername/yourfoldername/yourfilename.sh in my case chmod +x /home/trinidad/rdv1/virdsk1.sh. See images below:
Next locate your .bashrc file in your home directory and open it with gedit. Just above the commented out bash alias instructions add your alias. Follow the format alias youralias=’/home/yourusername/yourfoldername/yourfilename.sh’ or in my case as it is shown alias virdsk=’/home/trinidad/rdv1/virdsk1.sh’. DO NOT use x11vnc anywhere in the alias. Save the file and close gedit. Now when you login to SSH you’ll be able to type a short alias into the terminal to start x11vnc with your settings already configured and editable.
**Tip** In my office at the shop I have two other computers running through a hub connected this way to one of my Debian computers. This VNC setup enables me to run them without monitors, not completely headless, the keyboard and mouse still connected to them, but all that under the bench and only one monitor, keyboard and mouse for work on the desk. Simply set them to auto-login, SSH to them and start a VNC session. I can share my wifi Internet connection to them, and they can both be shutdown from VNC as well.