5

I am using mac os 10.8.2, and connecting to a cloud computing cluster through Xquartz.

I do:

ssh -CY <uname>@serveradress
and then ./<softwaretoopen>

and it opens the software perfectly fine, but it is common that for some reason I loose the connection, and then when I try again I get the error:

ssh -CY <uname>@serveradress
and then ./<softwaretoopen>
Xlib: connection to "<servername>" refused by server
Xlib: Invalid MIT-MAGIC-COOKIE-1 key

Then if I restart my computer and try again it's good again, but this is becoming extremely annoying since everytime I get disconnected have to close all open software, restart computer and try connecting again.

Any idea how to solve such issue?

Thanks in advance!

2 Answers 2

6

I found the asnwer in link at the bottom of the page.

Basically what I have to do without restarting the computer is to:

rm ~/.Xauthority*

On the server, then close X11, then re-open X11 and connect to the server again.

Thanks!

http://slopjong.de/2011/06/14/invalid-mit-magic-cookie-1-key/

3
  • 2
    JUst to update about it, it does not work all the time not sure why, if someone has more advice I'd be happy to hear about it, thanks!
    – Dnaiel
    Jan 28, 2013 at 17:50
  • 1
    Yes rm ~/.Xauthority* works fine for me too. Just to add to above answer, the "server" refers to local machine, from which you want to view the GUI and client refers to the remote machine on which the UI process (e.g. eclipse, xclock) has to be started. Aug 19, 2015 at 9:38
  • for me not. check here: unix.stackexchange.com/questions/659362/… . Newest installations of debian make as default easy as hostname for whatever reasons. this created a lot problems for me. check sysctl.conf, set kernel.hostname=NAME, and populate changes in bashrc adding sysctl -p --system -w. Also, cat .Xauthority to check what is the hostname given there. But sysctl was not needed if i edit that here sudo nano /var/lib/dhcp/dhclient.enp3s0.leases and change it. Jan 2 at 10:56
0

This could be one of the reasons you could get the following error:

Invalid MIT-MAGIC-COOKIE-1 keyError: Can't open display: :1

Make sure you are running any GUI process from the same user where vncserver process is owned by.

For example:

venkat@home-laptop:~/Downloads/$ ps -eaf | grep vnc
venkat    3504     1  0 Apr06 ?        00:09:52 /usr/bin/Xvnc :1 -auth /run/user/1000/gdm/Xauthority -desktop home-laptop:1 (venkat) -fp /usr/share/fonts/X11//misc,/usr/share/fonts/X11//Type1 -geometry 1024x768 -pn -rfbauth /home/venkat/.vnc/passwd -rfbport 5901 -rfbwait 30000
venkat   10595  8391  0 02:33 pts/5    00:00:00 grep --color=auto vnc
venkat@home-laptop:~/Downloads/$
venkat@home-laptop:~/Downloads/$
venkat@home-laptop:~/Downloads/$ sudo -i
root@home-laptop:~#
root@home-laptop:~# xclock
Invalid MIT-MAGIC-COOKIE-1 keyError: Can't open display: :1
root@home-laptop:~#
root@home-laptop:~#
root@home-laptop:~# exit
logout
venkat@home-laptop:~/Downloads/$
venkat@home-laptop:~/Downloads/$ xclock

So run both the vnc server & gui process as same user as possible from local ssh terminal.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .