X11 connection rejected because of wrong authentication after sudo to another user

This is a posting for my reference. I lifted this from Jianming Li in case one of these days he decides to take it down.

Cause: X win cookie not carried over after sudo login as another user.

Solution: Add the cookie to the other user.

From user1

>> echo $DISPLAY
>> xauth list
box.my.com/unix:10  MIT-MAGIC-COOKIE-1  4f76c629f8cdbf26ce4ae646cc24448c
box.my.com/unix:11  MIT-MAGIC-COOKIE-1  1acd10ab0fd098a86aba7aa691d7c067
box.my.com/unix:12  MIT-MAGIC-COOKIE-1  e007ee6844c417a6b866d66c7bbcbc7d

From User2 (even root)

>> sudo su >> DISPLAY=localhost:10.0; export DISPLAY >> xauth add

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s