Error Putty X11 proxy: Authorisation not recognised

48,127

Solution 1

I had the same problem and found the solution. The reason of the error is not passing the MIT-MAGIC-COOKIE-1 to the root. This file is stored on ~/.Xauthority. You have three options.

1) Quick fix would be loading all the user environment

$ sudo -E python myscript.py

-E option would load root shell environments from user's home directory. So, ~/.Xauthority of the user will be read. However, this is kinda brute force and not really recommended for security concern.

2) list the key and load it to root /root/.Xauthority

Another way to directly load the key to root .Xauthority.

pi@RPi-Dev:~$ xauth list
RPi-Dev/unix:10  MIT-MAGIC-COOKIE-1  5cxxxxxxxxxxxxxxxxxxxxxxxxxxx3d3
pi@RPi-Dev:~$ sudo -s
root@RPi-Dev:/home/pi# xauth add RPi-Dev/unix:10  MIT-MAGIC-COOKIE-1  5c5cxxxxxxxxxxxxxxxxxxxxxxxxxxxd3

3) setup and passing XAUTHORITY environment value.

You can specify .Xauthority file with XAUTHORITY, however, by default it's not set and just load the file from ~/.Xauthority. So, give sudo option this way.

$ sudo XAUTHORITY=${HOME}/.Xauthority python myscript.py

root will get XAUTHORITY=/home/(user)/.Xauthority, and read the file accordingly.

Solution 2

It would be likely that sudo is causing the problem. To check, you can run an X application (e.g. xeyes) without sudo. If this works, you can run your python script by adding the xauth cookie to root:

dave@raspberrypi$ xauth list
raspberrypi/unix:10  MIT-MAGIC-COOKIE-1  1e656e1......2d6d5a

dave@raspberrypi$ sudo su 
# paste in the output from 'xauth list' below:
root@raspberrypi$ xauth add raspberrypi/unix:10  MIT-MAGIC-COOKIE-1  1e656e1......2d6d5a

dave@raspberrypi$ sudo python myscript.py
Share:
48,127

Related videos on Youtube

Dave
Author by

Dave

Updated on September 18, 2022

Comments

  • Dave
    Dave over 1 year

    I'm developing a robot with a Raspberry Pi, and I'm having trouble with X11 forwarding. When I'm going to run my script as:

       sudo python myscript.py
    

    I get the error:

       Putty X11 proxy: Authorisation not recognised
       (Imagen Combinada:3642) : Gtk-Warning **: cannot open display: localhost:10.0
    

    I'm using PuTTY with Xming(Enabling SSH -> X11 -> Enable X11 Forwarding).

    Does someone know what can be happening here and how could I solve it?

  • Dave
    Dave almost 9 years
    Thanks!! Solved with lxsession an running everything from the root terminal!