TIP: X forwarding after su’ing to another user
by daven on Oct.19, 2008, under General System Administration, Quick Tips
It is a fairly common occurrence now days for security purposes to disable remote login access for “role accounts” like Oracle or Mysql. This restricts you to logging as a normal user then using the su command to become the role users. It works great in almost every circumstance but what if you need access to a remote X display while su’ed to the role account? Just trying to run the X program as normal will give you an error.
So what do you do? Why you find the Magic Cookie!
Before doing su to the become the new user do
$ xauth list
You should get back a result that looks something like this
hostname.domainname.com:11 MIT-MAGIC-COOKIE-14d22408a71a55b41ccd1657d7923ae
Now that you have your Magic Cookie don’t forget to stock up on the munchies.
su to the new user and tell it what the Magic Cookie is so it can communicate with the Xserver.
su - someuser
password: *******
xauth add MIT-MAGIC-COOKIE-14d22408a71a55b41ccd1657d7923ae
Then export X programs as normal