Thursday, February 9, 2012

X11 connection rejected because of wrong authentication.



When you need to run an X window application over SSH.
You ssh -X into the remote machine, running X applications works fine, until you
sudo or su to another user to run an X application , You get the following error.
"X11 connection rejected because of wrong authentication.

X connection to localhost:10.0 broken (explicit kill or server shutdown)."

or if you connected using putty the error will read.
Xlib: PuTTY X11 proxy: wrong authentication protocol attempted”.


How to fix?


ssh cgerada@remote-server -X


cgerada $ su – oracle
oracle‘s Password:
oracle $ xclock


"X11 connection rejected because of wrong authentication.
X connection to localhost:10.0 broken (explicit kill or server shutdown)".

or if you connected with putty the error reads


"Xlib: PuTTY X11 proxy: wrong authentication protocol attempted
xclock Xt error: Can’t open display: localhost:10.0"


On newer versions of  OpenSSH Server releases, you can simply enable “ForwardX11Trusted yes” in the /etc/ssh/sshd_config file and restart the OpenSSH server.
If you’re using an older version of  OpenSSH Server release then
You need to temporarily transfer the authorization to the other account. First, get the key from your account:
cgerada $ xauth list
fileserver/unix:10  MIT-MAGIC-COOKIE-96951c0622f80fd52186129dd06f2f6
Next, sudo/su to the other account and add the authorization key.
cgerada $ su – oracle
oracle $ xauth add fileserver/unix:10  MIT-MAGIC-COOKIE-96951c0622f80fd52186129dd06f2f6
Now, you should be able to start any X Windows application, 
oracle $ xclock

No comments: