0

UPDATE 1: I am not using SSH. I am using a local machine.

UPDATE 2: I restarted the X and notice that the Xauthority file that I am exporting to is actually being updated:

$ sudo systemctl restart display-manager
$ ls /run/user/1000/gdm/Xauthority*
-rwx------ 1 mona mona 96 Jan 25 16:07 /run/user/1000/gdm/Xauthority

Also, after I restarted the X, the other two Xauthority files, namely /run/user/1000/gdm/Xauthority-c and /run/user/1000/gdm/Xauthority-l, are gone as can be seen below:

$ fd Xauthority /
/run/user/1000/gdm/Xauthority

and I can call xauth after reboot:

$ xauth
Using authority file /run/user/1000/gdm/Xauthority
xauth> 

Following "Invalid MIT-MAGIC-COOKIE-1 key" when trying to run program remotely I tried:

[9080:9072 0:2035] 02:14:50 Mon Jan 25 [mona@goku:pts/0 +1] ~/research/code/vision/integration
$ export DISPLAY=desktop:0
18838/31772MB(vision)

and then:

$ xhost +local: 
xhost:  unable to open display "desktop:0"

how could I fix this problem?

$ lsb_release -a
LSB Version:    core-11.1.0ubuntu2-noarch:security-11.1.0ubuntu2-noarch
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.1 LTS
Release:    20.04
Codename:   focal

Another similar example:

$ xclock
Error: Can't open display: desktop:0

More details:

$ xclock
Error: Can't open display: desktop:0
27296/31772MB
[3266:3258 3:2008] 02:54:16 Mon Jan 25 [mona@goku:pts/0 +1] ~
$ export DISPLAY=":0.0"
26016/31772MB
[3266:3258 3:2009] 02:57:24 Mon Jan 25 [mona@goku:pts/0 +1] ~
$ xclock
Invalid MIT-MAGIC-COOKIE-1 keyError: Can't open display: :0.0
$ export DISPLAY=":0"
26238/31772MB
[3266:3258 3:2011] 02:57:40 Mon Jan 25 [mona@goku:pts/0 +1] ~
$ xclock
Invalid MIT-MAGIC-COOKIE-1 keyError: Can't open display: :0
$ xhost +mona
Invalid MIT-MAGIC-COOKIE-1 keyxhost:  unable to open display ":0"
$ firefox
Invalid MIT-MAGIC-COOKIE-1 keyUnable to init server: Could not connect: Connection refused
Error: cannot open display: :0

$ xclock Invalid MIT-MAGIC-COOKIE-1 keyError: Can't open display: :0 25694/31772MB [3266:3258 3:2026] 03:04:35 Mon Jan 25 [mona@goku:pts/0 +1] ~ $ export DISPLAY=desktop:0 25694/31772MB [3266:3258 3:2027] 03:04:49 Mon Jan 25 [mona@goku:pts/0 +1] ~ $ xclock Error: Can't open display: desktop:0

Also, I am having weird characters in Xauthority file:

$  xrandr | nc termbin.com 9999
Invalid MIT-MAGIC-COOKIE-1 keyCan't open display :0
21618/31772MB
[9136:3258 0:2002] 03:49:16 Mon Jan 25 [mona@goku:pts/2 +1] ~
$ fd Xauthority /
/run/user/1000/gdm/Xauthority
/run/user/1000/gdm/Xauthority-c
/run/user/1000/gdm/Xauthority-l
22048/31772MB
[9136:3258 0:2003] 03:51:26 Mon Jan 25 [mona@goku:pts/2 +1] ~
$ cat /run/user/1000/gdm/Xauthority-c
22048/31772MB
[9136:3258 0:2004] 03:51:49 Mon Jan 25 [mona@goku:pts/2 +1] ~
$ cat /run/user/1000/gdm/Xauthority-l
22081/31772MB
[9136:3258 0:2005] 03:51:58 Mon Jan 25 [mona@goku:pts/2 +1] ~
$ cat /run/user/1000/gdm/Xauthority
gokuMIT-MAGIC-COOKIE-1R��9��s{�H��H�l��gokuMIT-MAGIC-COOKIE-1R��9��s{�H��H�l22081/31772MB
[9136:3258 0:2006] 03:52:03 Mon Jan 25 [mona@goku:pts/2 +1] ~

Also, setting it to the found Xauthority file didn't solve the problem:

$ export XAUTHORITY=/run/user/1000/gdm/Xauthority
22022/31772MB
[9136:3258 0:2010] 03:54:31 Mon Jan 25 [mona@goku:pts/2 +1] ~
$ xclock
Invalid MIT-MAGIC-COOKIE-1 keyError: Can't open display: :0

I am uid 1000:

uid=1000(mona) gid=1000(mona) groups=1000(mona),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),120(lpadmin),131(lxd),132(sambashare)

I also have these about xauth:

$ xauth info Authority file: /run/user/1000/gdm/Xauthority File new: no File locked: no Number of entries: 2 Changes honored: yes Changes made: no Current input: (argv):1 21740/31772MB [11979:11971 0:2016] 05:26:34 Mon Jan 25 [mona@goku:pts/0 +1] ~ $ xauth list goku/unix: MIT-MAGIC-COOKIE-1 SECRET_KEY #ffff#676f6b75#: MIT-MAGIC-COOKIE-1 SECRET_KEY

enter image description here

  • 1
    Notice that in the Q&A you link to the desktop in desktop:0 is a placeholder for actual hostname of the machine. Does ping desktop work? But you better present your case from the start -- that Q&A you link to may be a dead end, with a problem completely different from yours. –  Jan 25 '21 at 20:14
  • no $ ping desktop ping: desktop: Temporary failure in name resolution – Mona Jalal Jan 25 '21 at 20:15
  • my problem is stuck at whatever x program I run with this error Error: Can't open display: desktop:0 – Mona Jalal Jan 25 '21 at 20:16
  • Where are you trying to start that program from? Have you connected with ssh to another machine, as in the Q&A you link to? –  Jan 25 '21 at 20:22
  • I am not using SSH. I am running everything in a local machine ( a laptop). – Mona Jalal Jan 25 '21 at 20:26
  • @Quasímodo please check the screenshot I have uploaded to the end of this post. – Mona Jalal Jan 25 '21 at 20:48
  • Try setting export XAUTHORITY=/run/user/1000/gdm/Xauthority (BTW that's a binary, not a text file -- the junk characters are OK). –  Jan 25 '21 at 20:51
  • @user414777 $ export XAUTHORITY=/run/user/1000/gdm/Xauthority 22022/31772MB [9136:3258 0:2010] 03:54:31 Mon Jan 25 [mona@goku:pts/2 +1] ~ $ xclock Invalid MIT-MAGIC-COOKIE-1 keyError: Can't open display: :0 – Mona Jalal Jan 25 '21 at 20:54
  • @Quasímodo this is not my realm. Could you please provide a bit more step-by-step solution including the commands for doing so or link me with something that does so? – Mona Jalal Jan 25 '21 at 20:55
  • You can usually do that from the button in the top right corner and then clicking on your username > Log Out. But I suspect that something else's broken. Eg. with your terminal emulator. –  Jan 25 '21 at 20:59
  • 1
    in the 3rd paragraph of code, I can't disentangle the code from prompts and other stuff. Post code without prompts, to make it readable. – ctrl-alt-delor Jan 25 '21 at 21:16
  • @ctrl-alt-delor please forget about the code. I cannot even run xclock command. – Mona Jalal Jan 25 '21 at 21:17
  • @ctrl-alt-delor I followed your suggestion and removed the $ so it automatically is recognized as Python. However, please let's focus on getting xclock fixed. – Mona Jalal Jan 25 '21 at 21:18
  • If you should forget about your code, then why is it in the question? – ctrl-alt-delor Jan 25 '21 at 21:18
  • @ctrl-alt-delor the code was an example that produces the problem, however, the problem is much bigger and is also produced by else thing. Please have a look at my initial post that was dealing with the code. https://askubuntu.com/questions/1310286/qt-qpa-plugin-could-not-load-the-qt-platform-plugin-xcb-in-even-though-it thank you – Mona Jalal Jan 25 '21 at 21:20
  • 1
    If it is confusing me then it is distracting me form answering the question, as evident by this comment thread. – ctrl-alt-delor Jan 25 '21 at 21:23
  • @ctrl-alt-delor thanks for your feedback. Removed the code and the error altogether to focus on the most pressing issue. The code and error are here https://pastebin.com/raw/hZtxBRTt – Mona Jalal Jan 25 '21 at 22:02

1 Answers1

0
$  export DISPLAY=:1.0

worked for me.

enter image description here

  • Yes I was just staring to wonder, if you had 2 X sessions running: I just noticed he screen shot of a perfectly functional X session, with you messing with stuff, and said "I wonder if you are trying to control another session?" – ctrl-alt-delor Jan 25 '21 at 22:33