Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

No matter how much you want to escape running graphical applications on a remote Linux server there are times (like when configuring Oracle WebLogic domains for example) that you are forced to do so. Sometimes, the user you have to be running these applications as is not the same as the your login user, this leads to errors like this...
 Error
X11 connection rejected because of wrong authentication.
Error: Can't open display: localhost:10.0


Ooops! This is easy to resolve though.

Before continuing, make sure you are running ssh with the -X switch (and that you have an X11 server running on your machine). Now after logging in as your initial user, do this:
 Terminal
xauth list


That will give you some output similar to this...
 Terminal
myhost.mydomain.com/unix:10 MIT-MAGIC-COOKIE-1 1183c75928e9dc95378aa3172b142652


Take note of the above and change to the user you need to run the graphical app as...
 Terminal
sudo su - appuser




Now you need to run xauth again, but this time not using 'list' but 'add' and after the 'add' command you provide the info that the 'list' command gave you above, like so...
 Terminal
xauth add myhost.mydomain.com/unix:10 MIT-MAGIC-COOKIE-1 1183c75928e9dc95378aa3172b142652


Then if everything went right, you can run your graphical app (xclock in the screenshot below).
xclock.png


-i

A quick disclaimer...

Although I put in a great effort into researching all the topics I cover, mistakes can happen. Use of any information from my blog posts should be at own risk and I do not hold any liability towards any information misuse or damages caused by following any of my posts.

All content and opinions expressed on this Blog are my own and do not represent the opinions of my employer (Oracle). Use of any information contained in this blog post/article is subject to this disclaimer.
Hi! You can search my blog here ⤵
NOTE: (2022) This Blog is no longer maintained and I will not be answering any emails or comments.

I am now focusing on Atari Gamer.