X11vnc
x11vnc is a VNC server that shares your physical X session. It can be started from a running X session by running:
x11vnc -many
It can also be started on system start-up. This is insecure and should only be used for firewalled home networks.
Get it
Download x11vnc from http://www.karlrunge.com/x11vnc/#downloading
Install it
Main article: installing software
This article takes version 0.9.5 as an example, but it should work similar with any version. Unpack x11vnc:
tar xvzf x11vnc-0.9.5.tar.gz cd x11vnc-0.9.5/ ./configure && make && make install
If you wish, you can also use a precompiled binary package.
Running x11vnc at boot
The following instructions are designed for Ubuntu and its sister projects, but will also work for other GNU/Linux distributions with minor changes.
This x11vnc how-to was originally written by ErikTheRed and can be found at the Ubuntu forums.
The original version of the how-to used xinetd, but other inetd daemons can also be used.
Using with KDM
These additional steps are needed if and only if you use the KDM software to log in. Kubuntu uses KDM by default.
Add the following to /etc/kde3/kdm/kdmrc under [X-:*-Core]
AuthFile=/root/xauth
On non-Ubuntu distributions, the kdmrc file may be located in a different folder.
You can change the AuthFile to be something different, just make sure you have the same file in your server_args in your inetd services file.
Now, restart your computer (or Ctrl+Alt+Backspace to kill X) before continuing on to the next step.
Using with GDM
To use x11vnc with the GDM logon manager (used by Ubuntu, Xubuntu and Linux Mint but NOT by Kubuntu), add the following to /etc/gdm/gdm.conf-custom under the [daemon] section:
KillInitClients=false
(On other distributions, this file may have different name or be located in a different folder.)
Now, restart your computer (or Ctrl+Alt+Backspace to kill X) before continuing on to the next step.
Setup
x11vnc is very similar to vnc, except that it allows you to view display :0, the display that would currently be showing on your monitor if you were sitting at your computer.
HINT: Replace "sudo nano" with "gksu gedit" on GNOME or "kdesudo kate" on KDE for a graphical editor.
1. Install the packages
sudo aptitude install x11vnc openbsd-inetd tcpd
2. Run the following command
ps wwaux | grep auth
This command should output something like this:
root 3838 10.1 1.7 13308 8840 tty7 Ss+ 15:35 2:14 /usr/bin/X -br -nolisten tcp :0 vt7 -auth /root/xauth erik 5156 0.0 0.1 2800 752 pts/0 R+ 15:57 0:00 grep auth
Note the bold path after -auth, as you will need this for the next step
3a. Add the x11vnc service to inetd:
sudo nano /etc/inetd.conf
Add this line:
5900 stream tcp4 nowait root /usr/sbin/tcpd /usr/local/bin/x11vnc.sh
4a. Then edit /usr/local/bin/x11vnc.sh:
sudo nano /usr/local/bin/x11vnc.sh
Enter this into the new file:
#!/bin/sh /usr/bin/x11vnc -inetd -o /var/log/x11vnc.log -display :0 \ -auth /root/xauth -many -bg
Notice the bold path, this is where you put the path you found in step 2.
Now, to make the script executable, you have to run the command:
sudo chmod +x /usr/local/bin/x11vnc.sh
4b. If you use xinetd (openSUSE does) then skip steps 3a and 4a and put the following text into a new file named /etc/xinetd.d/x11vnc:
service x11vnc { port = 5900 type = UNLISTED socket_type = stream protocol = tcp wait = no user = root server = /usr/bin/x11vnc server_args = -inetd -o /var/log/x11vnc.log -display :0 -auth /var/run/xauth/A:0-LliKdB -many -bg disable = no }
5. Restart inetd
sudo /etc/init.d/openbsd-inetd restart
6. You can now connect to display :0 from another machine by using a VNC client. For example:
vncviewer vnchost:0
Using pre-0.9 versions of x11vnc with TightVNC Viewer
If you find problems when using TightVNC Viewer with x11vnc, add the -rfbversion 3.7 option to the x11vnc arguments.
If you are using xinetd, the server_args line will look like:
server_args = -inetd -o /var/log/x11vnc.log -display :0 -auth /var/run/xauth/A:0-LliKdB -many -bg -rfbversion 3.7
IMPORTANT: Replace the -auth part with your own from step 2.