Uncategorized

Use x11vnc to connect to existing X session

Today there was a need to be able to view my linux desktop (Gentoo + fluxbox) remotely. I also wanted to connect to the existing X session, and not create a new X session. I looked at vnc and tightvnc, but documentation was stating that either would be able to connect to an existing session. Here is where x11vnc comes in. To get this working I needed to emerge x11vnc and install vncviewer on my Windows XP laptop. This setup was incredibly easy and I was up and running in a matter of minutes.

Today there was a need to be able to view my linux desktop (Gentoo + fluxbox) remotely. I also wanted to connect to the existing X session, and not create a new X session. I looked at vnc and tightvnc, but documentation was stating that either would be able to connect to an existing session. Here is where x11vnc comes in. To get this working I needed to emerge x11vnc and install vncviewer on my Windows XP laptop. This setup was incredibly easy and I was up and running in a matter of minutes.


emerge -pv x11vnc

After the package has been installed and emerge’d it’s time to configure it.


vi ~/.x11vncrc


forever
localhost
rfbauth /home/your_user_name/.vnc/passwd
display :0

As you can see, we need to create a passwd file. We’ll do this via x11vnc


x11vnc -storepasswd <YOUR_PASSWORD_HERE> ~/.vnc/passwd

In my situation I have the x11vnc server on my local network, and I’m going to be VPN’ing to my internal network. Please refer to my OpenVPN how-to. So on my x11vnc server, I’m planning on starting the service by hand.. but I’ll probably add this to my .xinitrc eventually. I want the service to listen for any requests and allow from my OpenVPN firewall, so here are the commands needed to be passed on startup:


x11vnc -listen 10.0.0.10 -allow 10.0.0.1 >>~/.x11vnc.log 2>&1 &


10.0.0.10 is my x11vnc server
10.0.0.1 is my OpenVPN service/firewall

Make sure your service is running with netstat -lnp


tcp 0 0 10.0.0.19:5900 0.0.0.0:* LISTEN 30860/x11vnc

I can’t stress to be carefull with this, you wouldn’t want this world touchable. I would also recommend using a VPN to connect as well. I’m sure there are ways to better protect the service, but that is beyond the scope of this how-to.

On the client end, you’ll need to download the vncviewer. I had some trouble finding a download.. for some reason, they all seemed to be down, but I did find a FTP download of the binary:

http://ftp.bauru.unesp.br/Windows/vnc_x86_win32/vncviewer/

Double click on the executable, and type in the address and session ie ( 10.0.0.10:0 )

Good luck!