Tombuntu

Remote Access From Windows - X11vnc

X11vnc is an easy way to remotely access your Linux desktop from another Windows (or Linux) computer. In this post I will explain how to use X11vnc to securely access your Linux computer from Windows. X11vnc is a VNC server. A VNC server sends images of an X display to a client whenever the display changes. The default VNC server for Linux is Xvnc, which creates a virtual X display that is not displayed on a monitor. X11vnc is different from Xvnc because it works with X displays that are used with a real monitor. This is useful because you can connect to your normal desktop and use any applications you have left open. X11vnc is also easier to set up than a VNC server that creates a virtual display. Because VNC is insecure, you should tunnel it through SSH as I will show you here.

The first step is installing X11vnc and a SSH server on the computer that you want to be able to connect to. This command will install both in Ubuntu or Debian. Of course if you already have an SSH server installed you don’t need to install it again, just leave off the last part of the command.

apt-get install x11vnc openssh-server

If you want to access your computer from outside your network you will need to forward port 22 to the computer running the SSH server. You can do this in your router’s setup. Before you expose the SSH server to the Internet, make sure your SSH password is unguessable. Forwarding a VNC port is not needed. Also, you will need to know your global IP address so you can connect to it. A service like No-IP can help you with this.

The easiest way to set up the tunneling for VNC on Windows is to use PuTTY. PuTTY is a graphical SSH client for Windows. You can either download the normal stand-alone version of PuTTY or download a portable version that does not write to the Windows registry. I would recommend the portable version if you want to use it from public computers. The last piece of software you need is a VNC client. There are many choices, but I would recommend the TightVNC client because of its simplicity (all you need to get is tightvnc-1.3.9_x86_viewer.zip). Once you have both PuTTY and TightVNC on the computer you want to connect from, you are ready to begin connecting. You may want to keep these two programs on a USB flash drive so you can easily run them from any computer. Start by running PuTTY.

PuTTY 1

PuTTY 2

Under “Host Name”, enter the IP address or host name of the computer you want to connect to and the port that the SSH server is on (22 by default). Then go to the Connection>SSH>Tunnels category. You need to create a tunnel from port 5900 to 127.0.0.1:5900. You can then save these settings back on the main screen so you don’t have to configure PuTTY every time. Click open and log in.

Once PuTTY is logged in you have a shell. Do not run these commands following as root or it will not work. Start X11vnc by running the command below. The first time it is run, X11vnc will ask for a password. Say yes to let it save to the default location. The server will then run.

x11vnc -usepw

TightVNC 1

Once the X11vnc server is running, start the TightVNC client. Connect to 127.0.0.1::5900. This address sends the VNC traffic through the encrypted tunnel. Enter the VNC password when prompted and you are done! TightVNC should display what is on the other computer’s monitor and you will have mouse and keyboard control. When you are finished, close TightVNC. The X11vnc server will automatically quit. Then you can exit PuTTY.

Good luck! If you can’t get it to work, leave a comment and I can try to help you out.

Archived Comments

wayne

Thanks for the guide. I’ve done this several times in different versions of Linux. However, I tried in PCLinuxOS and cannot get x11vnc to install. I run ‘sudo apt-get install x11vnc’. It goes through the installation process, does not seem to fail at any point, but then when I try to execute x11vnc, it says the command is not found. I’ve even run ‘find / -name x11vnc -print’ (as root) and it returned zero results. Am I missing something? The x11vnc file should be somewhere since I installed the package.

I even tried installing x11vnc through the graphical Synaptic utility.

ryall

Is there any way to start x11vnc automatically when the system boots?

Tom

ryall:
x11vnc will only work while a user is logged in to X, so you’d have to set up automatic login on boot first (System->Administration->Login Window->Security). Then you could add x11vnc to your session to start it after the login (System->Preferences->Sessions).

andi

nice entry,

but how can i remote ubuntu server ,start before login to GNOME?

thank’s alot

xe2bss

I installed x11vnc for Solaris 10 (SPARC) and when trying to follow the instructions above trying to connect from a Windows XP PC I have the following:

$ ./x11vnc -usepw
29/01/2009 14:40:06 passing arg to libvncserver: -usepw

Settings:
display: null
authfile: null
subwin: 0x0
rootshift: 0
flashcmap: 0
force_idx: 0
overlay: 0
ovl_cursor: 1
visual: null
scaling: 0 1.00000
viewonly: 0
shared: 0
conn_once: 1
inetd: 0
connect: null
connectfile null
vnc_conn: 1
allow: null
passfile: null
accept: null
gone: null
using_shm: 1
flipbytes: 0
onetile: 0
blackout: null
xinerama: 0
xrandr: 0
xrandrmode: null
logfile: null
rc_file:
norc: 0
bg: 0
mod_tweak: 1
isolevel3: 0
xkb: 0
skipkeys: null
addkeysyms: 0
xkbcompat: 0
clearmods: 0
remap: null
norepeat: 1
nofb: 0
watchbell: 1
watchsel: 1
watchprim: 1
cursor: 1
root_curs: 0
curs_mode: null
xfixes: 1
cursorshp: 1
cursorpos: 1
xwarpptr: 0
buttonmap: null
dragging: 1
ptr_mode: 2
inputskip: 10
debug_ptr: 0
debug_key: 0
defer: 30
waitms: 30
take_naps: 0
sb: 60
sigpipe: null
threads: 0
fs_frac: 0.75
gaps_fill: 4
grow_fill: 3
tile_fuzz: 2
deny_all: 0
noremote: 0

29/01/2009 14:40:06 x11vnc version: 0.7pre lastmod: 2004-12-23
29/01/2009 14:40:06 XOpenDisplay failed (null)

And of course it does not work.

Any ideas please?

Thanks

xury

Excellent ! I tried using IPv6 tunnelling and working perfectly.

Andy

Hi!
Thanx for the tutorial. But:
UltraVNC and TightVNC wont allow a loop-back connection… Where can I enable this?

New Linux User

OMG… thank you for this. I would have never figured out how to SSH tunnel from my Winbox to my Linbox without your tutorial.

Remote Access

I have to agree with the above comment. I don’t think I could have ever figured this out on my own. I do use multiple solutions for these connections, but I always like to tinker when possible.

Chris

Thank-you for this. I tried a number of other websites but connected first time using your instructions.

Anonymous

good articles! very useful!!!!!!!!!!!

juzaw

good article! very useful!
thz!!

bx

Awesome! thanks for the great walk through on how to set this up.

aspirin

Excellent summary, thanks a lot! :)

d0pevogel

Hi great post.

However not working for me, as i keep getting “failed to connect to server” errors.

Is there any way to check if windows mapped the tunnel correctly ?

KR
d0pevogel

Steve

Thanks! Worked flawlessly

I have a question though…

What if I wanted to enable multiple users to connect Is there a way to share x11vnc?

HappyHappyJoyJoy

This worked for me. Many thanks!

Respond via email