X11: Invalid MIT-MAGIC-COOKIE-1 keyError: Can't open display: :0 on Ubuntu 16.04

10,596

I fixed the problem. I added passwords to students with sudo passwd username After that, I tried to get into user environment by using ssh username@ip, then I did who and saw the :0 or :1 as a display number. I used export DISPLAY=:0 or :1 then I ran xeyes command and HEYYYYYYY, IT WORKED! (Pardon my excitement)

I used this website.

It gave me a hint about what to do next.

Share:
10,596

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin almost 2 years

    I want to open GUI applications (xeyes, firefox, xlock etc) on remote computer by using SSH from Local computer to connect to remote computer. Local PC--> SSH to --> Remote PC I have two computers. I use one computer that I like the most. Let's call it "main" or "local". Second computer is just a doll for me, lab to test my experiments on. Let's call it "guinea pig" or "remote".

    I have a problem, that has been with me for so long. I don't know how to fix it. Example:

    ssh -p 22 IP address
    xclock (shows clock on local PC [main])
    who
    student102 tty7         2019-02-13 10:54 (:0)
    admin pts/2        2019-02-13 13:23 (IP address)
    export DISPLAY=:0
    xclock (Error: Invalid MIT-MAGIC-COOKIE-1 keyError: Can't open display: :0
    

    I have tried ssh -Y and ssh -X and same result. Same error. What should I do? Reinstall Ubuntu? Reinstall SSH and Xorg? How can I fix this error?

    • steeldriver
      steeldriver over 5 years
      It looks like you are SSHing as user admin - but trying to run xclock on a display owned by user student102?
    • Admin
      Admin over 5 years
      Yeah. I figured that export DISPLAY=:0 or whatever student102 uses works but I get this error.
  • Gringo Suave
    Gringo Suave almost 4 years
    I had to login first as the user at the graphics station tty7 with sudo su - username, then it worked.