XAuth after su

Sometimes we need to SSH onto a server using a different user to the one we need to load GUIs as. XAuth won’t work now as the MAGIC-COOKIE won’t match for security.

Try this to get it working:

SSH on to the box and run:
linux> xauth list
server/unix:15 MIT-MAGIC-COOKIE-1 55bbe5a4667b019dfffa3aa8c4fdb60c
server/unix:12 MIT-MAGIC-COOKIE-1 c7e2fd2f064fd5d46786f36b253a60dc
server/unix:11 MIT-MAGIC-COOKIE-1 1ebb83a90adb138abad824daa934aa2c
server/unix:14 MIT-MAGIC-COOKIE-1 c025881cf3682f89f0458ea8cc5b4921
server/unix:10 MIT-MAGIC-COOKIE-1 8b37eeb88c4109f769dae2f5d4fa0fb7
server/unix:13 MIT-MAGIC-COOKIE-1 c3e1691060e8d4ffa9f0879db2d91e37
server/unix:16 MIT-MAGIC-COOKIE-1 f2e9cca007dc835f057cf6a859c58dff

Find which is your DISPLAY
linux >echo $DISPLAY

su to ‘new’ user
Set the cookie to the number matching your display
linux> xauth add server/unix:10 MIT-MAGIC-COOKIE-1 8b37eeb88c4109f769dae2f5d4fa0fb7

Ta dah. Enjoy

Leave a Reply