Magic Cookies for X Forwarding

07 Oct 2014

The Problem

I have access to a server that I am installing Oracle software on but when I do an su to another user I lose the ability to do X Forwarding and so can’t see the GUI install tools.

Here’s an example of what I see:

can\'t open a display from oracle user
oracle@te-pythia-mimic:/oracle/software/source/database> xclock 
Error: Can't open display: 

To get round this I need some information about the current DISPLAY I am using and the access authorization settings.

te-pythia-mimic:~ > xauth list
te-pythia-mimic/unix:10  MIT-MAGIC-COOKIE-1  42b7b5e94971b6eb1c9eb700ffde0aa0

te-pythia-mimic:~ > echo $DISPLAY
localhost:10.0

Once I have this info I can switch user and re-configure my new users environment.

Switch user:

te-pythia-mimic:~ > su - oracle
oracle@te-pythia-mimic:~> export DISPLAY=localhost:10.0

Have a look at the xauth list

oracle@te-pythia-mimic:~> xauth list
xauth:  creating new authority file /opt/oracle/.Xauthority

Now to setup xauth to allow the new user

oracle@te-pythia-mimic:~> xauth add te-pythia-mimic/unix:10  MIT-MAGIC-COOKIE-1  42b7b5e94971b6eb1c9eb700ffde0aa0
xauth:  creating new authority file /opt/oracle/.Xauthority

Testing:

oracle@te-pythia-mimic:~> xclock 
  • works a treat