"Could not connect to display" in one user account

45,555

Solution 1

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

Solution 2

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
Share:
45,555

Related videos on Youtube

trivelt
Author by

trivelt

Updated on September 18, 2022

Comments

  • trivelt
    trivelt almost 2 years

    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.

    • Admin
      Admin almost 10 years
      When you ssh are you trying to display on the local or remote machine?
    • Admin
      Admin almost 10 years
      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.
    • Admin
      Admin almost 10 years
      You also need to use xauth, though I can not remember the detail. Another option is to use X11vnc
    • Admin
      Admin almost 10 years
      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.
    • Admin
      Admin almost 10 years
      @richard: thanks! I installed x11vnc and it works. Earlier I had only xvncviewer.
  • ctrl-alt-delor
    ctrl-alt-delor almost 10 years
    Danger, danger: don't do xhost +, unless the network you are connected to is secure. So if you are connected to the internet, and don't have a tested fire wall that will block X11… then don't do this. If you are considering using xhost then you should be considering xauth as it is much more secure.
  • AdminBee
    AdminBee almost 4 years
    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 ...