Tuesday, December 1, 2015

Install a VNC Server on Ubuntu (x11vnc as alternative to tightVNC)

The goal of a VNC server is to remotely access the screen of another machine. In my case remotely is a room further down the hall on the same intranet, so at this stage I'm not worried about using encryption.

After having some trouble using the very popular tightvnc as a the tool of choice (I was getting errors running software which are based on the Qt framework; a similar bug has been reported here).
Because I'm quite dependent on this particular piece of software, I had to find a workaround. I chose to use x11vnc.

Because x11vnc relies on an actual X display, we need to make a virtual X display first. For this I use Xvfb. Both x11vnc and Xvfb are available in the Ubuntu repositories.
Additionally, I wanted to use the old Gnome-Fallback (a.k.a Gnome Classic) display, because I'm not a big fan of the current display and the 3D-effects make things go slower on a VNC connection. This can be installed using sudo apt-get install gnome-session-fallback. This is of course not a requirement to use x11vnc and Xvfb.

First generate a password for x11vnc:
x11vnc -storepasswd and store it to /home/yourusername/.vnc/passwd. The password is only a minimal security measure, the connection still won't be encrypted.

You need to first start the Xvfb display this way:
/usr/bin/xinit /usr/bin/gnome-session --session=gnome-fallback --disable-acceleration-check -- /usr/bin/Xvfb :20 -screen 0 1680x1050x24
This will open an Xvfb display on X display number 20 with the given resolution (1680x1050) and color depth (24bit). If you don't want to use the classic gnome desktop remove the --session=gnome-fallback argument.

Next start x11vnc:
/usr/bin/x11vnc -display :20 -loop -rfbport 5901 -rfbauth /home/yourusername/.vnc/passwd -o /var/log/x11vnc.log
This will forward X display number 20 (where the Xvfb display is) to port 5901. Make sure that argument -rfbauth points to your password you created in the first step.

You can now connect to your machine on port 5901 using a VNC client such as RealVNC. Make sure that your firewall allows access to port 5901. You can of course also change the port using the -rfbport argument in x11vnc.

If everything works we can use a service to start these two programs automatically at every upstart.
As sudo create a text file at /etc/init/x11vnc.conf. Include following commands (make sure to replace yourusername with your actual username):
start on login-session-start
script
echo Start x11vnc at `date` >> /var/log/x11vnc.log
su - yourusername -c "/usr/bin/xinit /usr/bin/gnome-session --session=gnome-fallback --disable-acceleration-check -- /usr/bin/Xvfb :20 -screen 0 1680x1050x24" &
su - yourusername -c "/usr/bin/x11vnc -display :20 -forever -loop -rfbport 5901 -rfbauth /home/yourusername/.vnc/passwd -o /var/log/x11vnc.log" >> /var/log/x11vnc.log
end script

This script will be run on every startup or by using sudo service x11vnc start.

1 comment:

  1. Genewarrior Blog: Install A Vnc Server On Ubuntu (X11Vnc As Alternative To Tightvnc) >>>>> Download Now

    >>>>> Download Full

    Genewarrior Blog: Install A Vnc Server On Ubuntu (X11Vnc As Alternative To Tightvnc) >>>>> Download LINK

    >>>>> Download Now

    Genewarrior Blog: Install A Vnc Server On Ubuntu (X11Vnc As Alternative To Tightvnc) >>>>> Download Full

    >>>>> Download LINK aw

    ReplyDelete