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,

7 Answers7

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
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

1

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.

Milind R
  • 143
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).

Geremia
  • 151
  • 6
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

blueether
  • 101
0

I am using

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.4 LTS
Release:    22.04
Codename:   jammy

I found out xauth using

$ ps aux | grep -i auth
root         310  0.0  0.0      0     0 ?        I<   11:26   0:00 [nvme-auth-wq]
cdot        1692  0.6  0.3 3308976 104212 tty2   Sl+  11:28   0:01 /usr/lib/xorg/Xorg vt2 -displayfd 3 -auth /run/user/1000/gdm/Xauthority -nolisten tcp -background none -noreset -keeptty -novtswitch -verbose 3
cdot       11855  0.0  0.0  17868  2688 pts/0    S+   11:32   0:00 grep --color=auto -i auth

Then I ran following in my telnet session

$ x11vnc -xauth  /run/user/1000/gdm/Xauthority -display :0 -forever &

Now I remotely view my machine from vnc viewer with URL ip-address:port

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!