User Tools

Site Tools


linux:debian:vnc_server_setup

x11vnc Server Setup on Debian/Raspbian

First of all what is VNC?

When I was converting a kiosk with a touch panel, windows 7 installed, into Debian GNU/Linux I needed a tool for remote access other than ssh to solve the problems with GUI. I used Debian (jessie) with xfce window manager, which is a lightweight window manager. After some trial and errors with tightvncserver and vnc4server I found x11vnc server more practical (I just felt that way). x11vnc is available in the official repositories. For my project vnc server must not start a new session for each connection, instead it must start the current session logged in (visible display) for the regular user I created (who does not have root access). This becomes the display “:0” in vnc server. In this tutorial I will refer regular user as “theuser” after this point.

For security reasons you must not provide the vnc server password from the command line.
Instructions are applicable to the most Linux distributions including Raspbian or Kali Linux

First of all install x11vnc if not installed

aptitude update
aptitude install x11vnc

You should create a password for theuser

[email protected]:~$ x11vnc -storepasswd
Enter VNC password: ....
Verify password:    ....
Write password to /home/theuser/.vnc/passwd?  [y]/n y
Password written to: /home/theuser/.vnc/passwd

Let's create a bash script to start vnc server from command line as a background process. Save this file to a folder where “theuser” can access and execute it (e.g. home folder of theuser). For Linux beginners; you can create a file and put content like this (use command line) nano <filepath> then paste the bash code below and press Ctrl+X then press Y and Enter. You can paste with mouse right menu or Shift+Insert.

#!/bin/bash
x11vnc -display :0 -forever -shared -o /home/theuser/x11vnc.log -bg -rfbauth /home/theuser/.vnc/passwd

The parameters passed are;

-forever: If a client is connected, new connection does not end the previous connection.

-shared: If you want to enable multiple user logins simultaneously to vnc server

-bg: Server process returns to background after initialization

-o: write error output to the log file

-display: To mention the display number, it is :0 in our case

-rfbauth: authorization through passwd file

Do not forget to make the script executable

For Linux beginners; (use command line) chmod +x <filepath>

You may want to start the script (x11vnc server) as soon as theuser logs in. To do that, you must add the script path to the startup. You can add it using the xfce settings manager as below

Do not forget that even if you add a startup script, x11vnc server does not start before user login. You may implement auto login for theuser or you may start the script using ssh if theuser has already logged in.

Note: VNC server default port is 5900. If port 5900 is not available, server tries these ports 5901,5902, etc. Make sure you don't run multiple server instance at different ports unintentionally.

Note: Do not try to modify script to start vnc server as a service (init.d script), it does not work because an X session is created after user login.

If you are also looking for a VNC viewer, www.realvnc.com offers a quite good free vnc viewer for many platforms. I do not want to advertise their product but I do feel comfortable with it. Unfortunately, it lacks ssl support. For encryption purposes, you may implement ssh port forwarding and tunneling.

Which tutorials should be added more?
Real name Xfce Window Manager Tutorials Raspberry Pi Tutorials Linux File System Tutorials Linux SysAdmin Tutorials Debian Package Management Tutorials SSH Tutorials VPN Tutorials Database Tutorials Python Programming Language Tutorials Go Programming Langauge Tutorials
Elfaba          
Michael         
mohamed        
Ozan HACIBEKIROGLU (ozan)       
Count: 2 1 1 0 1 1 1 2 1 0

Discussion

Adam Brisebois, 2016/09/26 21:38

Thanks. Exactly what I was looking for. I had lost my howto on this exact procedure, and was very glad to find you wrote it up!

Most appreciated!

Annoy Orange, 2017/01/23 17:41

Thanks for this guide exactly what I was looking for, being a complete novice to Linux I was able to follow this guide on the latest stable release of Deb 8.7.1 an it worked perfectly. LOL

Ozan HACIBEKIROGLU, 2017/03/13 07:29

You are welcome :-)

Gaurav Saxena, 2017/04/25 02:32

Your tutorial helped me to run x11vnc on linuxcnc (Debian wheezy). Thanks a lot

Ozan HACIBEKIROGLU, 2017/04/27 07:55

You are welcome. Let me know if you need any other tutorial.

Taylan Tandoğan, 2017/07/13 00:27

gayet faydalı oldu.. Teşekkürler.

Enter your comment. Wiki syntax is allowed:
 
linux/debian/vnc_server_setup.txt · Last modified: 2017/06/25 12:41 by ozan