6

I have a GUI application written in Qt and I wanted to run tests by ssh (or Jenkins). There is only one user account, which allows to run it in display mode (ofc when I previously do export $DISPLAY=:0. On other user, jenkins, I saw an error in console:

QXcbConnection: Could not connect to display :0 
Aborted (core dumped)

What should I do to allow this user to run applications in graphical mode? I use Ubuntu 14.04.

Kusalananda
  • 320,670
  • 36
  • 633
  • 936
trivelt
  • 217
  • 1
  • 4
  • 10
  • When you `ssh` are you trying to display on the local or remote machine? – ctrl-alt-delor Aug 07 '14 at 10:32
  • On remote machine, but I also tried do it connecting by rdesktop and the result is the same - user1 can run application (and I see window etc.), but user2 can't. – trivelt Aug 07 '14 at 10:36
  • You also need to use `xauth`, though I can not remember the detail. Another option is to use X11vnc – ctrl-alt-delor Aug 07 '14 at 10:52
  • As a rule, you can't use another display. If you are in A, then ssh to B, you would have to display in A, you cannot display in B. – Archemar Aug 07 '14 at 11:16
  • @richard: thanks! I installed x11vnc and it works. Earlier I had only xvncviewer. – trivelt Aug 07 '14 at 11:52

3 Answers3

4

I run unit tests of my GUI application using QTestLib on a headless continuous integration server by setting up an X virtual framebuffer.

Xvfb :1 &
PID=$!
DISPLAY=:1 make check
kill $PID
Erik
  • 103
  • 2
Lucas
  • 161
  • 8
0

X11vnc may be what you want. It will allow you to share the entire desktop using vnc.

Alternatively for more control: to allow X11 to put individual windows on the display, and also on the local display, then use xauth to configure the security. Note xhost can also be used to do the same as xauth, but it is very insecure, it will allow any machine on your network to access your desktop, and control your applications (even if you use host based authentication).

ctrl-alt-delor
  • 27,473
  • 9
  • 58
  • 102
0

Based on @tveronesi solution you may allow only local connections to X server:

xhost +local:
QkiZ
  • 123
  • 7
  • Welcome to the site, and thank you for your contribution. However, would this approach not allow _all_ local connections? That might be more permissive than the OP wants ... – AdminBee Jul 24 '20 at 10:55