7

I have a ubuntu linux machine that I have already logged into and X server is running (it is pass the login manager like gdm). I can access this machine through ssh. My goal is to start x11vnc on this machine and attach it to the X server that is already running.

When I ssh into the machine and start x11vnc, it says:

X11 was unable to open the X DISPLAY ":0", it cannot continue.

How can I start x11vnc on the remote machine if I don't have physical access to it and Xserver has already started. The reason I want to do this is because the remote machine has several windows open that I want to work on.

EDIT: I also tried x11vnc -find. This time it didn't give me that error message and was able to detect that the client was connected:

Got connection from client x.x.x.x
...
wait_for_client: find display cmd failed
wait_for_client: bad reply '
'

So it seems like -find command just delays the inevitable.

Thanks,

6 Answers 6

4

I was using gnome so what I did was simply give x11vnc the x authority file gnome was using. This was done by:

x11vnc -xauth /var/lib/gdb/:0.Xauth -display :0
2
  • Very intriguing answer! This is useful elsewhere as well.
    – Mei
    May 30, 2010 at 18:02
  • 1
    The auth file might not always be the "/var/lib/gdb/:0.Xauth" in different OS. Sometimes we could reveal and guess it by ps wwwwaux | grep auth
    – Ekeyme Mo
    Nov 28, 2018 at 3:28
3

I found on my gentoo kde desktop this works great for when kde is already running.

x11vnc -xauth /var/run/xauth/A:0-bHJFac -display :0 -passwd "password" -forever -shared

0

For me

Description:    Debian GNU/Linux 6.0.5 (squeeze)
Release:        6.0.5
Codename:       squeeze

apt-cache policy gdm3
gdm3:
  Installiert: 2.30.5-6squeeze4

this worked well even if i log in remotely via ssh:

su -c "x11vnc -auth /var/run/gdm3/auth-for-username*/database -display :0 -forever -passwd foo"

edit: you could also use e.g. ssvnc for a comfortable use of vnc over ssh. Just start the x11vnc like above but with the "-localhost" option:

su -c "x11vnc -auth /var/run/gdm3/auth-for-username*/database -display :0 -forever -passwd foo -localhost"

then you can click on "Use SSH" in the ssvnc script and it would connect through ssh, so there is no need for x11vnc to listen globally!

0

I solved it in a very roundabout way, so I'm just going to detail how I did it, which is very suboptimal and involved. Others have already given elegant and short solutions.

The problem I faced was that x11vnc refused to start over SSH saying that it did not find any graphical display. So my solution to that was....

First, over SSH as root I started a TigerVNC server on the machine at display :1

# vncserver :1

(starting as root was stupid)

Then I connected to this display using TigerVNC from my client computer

Connect to: a.b.c.d:1

Now I'm in the GUI as root(very stupid). I opened a terminal, and started x11vnc as my original user

# sudo -u milind x11vnc -many -display :0

Now I was able to

Connect to: a.b.c.d:0

Done! albeit in a very roundabout manner.

0

Use x0vncserver instead:

x0vncserver is a TigerVNC Server which makes any X display remotely accessible via VNC, TigerVNC or compatible viewers. Unlike Xvnc(1), it does not create a virtual display. Instead, it just shares an existing X server (typically, that one connected to the physical screen).

0

For my situation, my machine was auto logged in as UserX and I was ssh'ed into the machine and running the x11vnc command as UserY

You must log in to answer this question.