When ssh -X to another host, I am able to use X-Windows.
[dinh@ca01ts~]$ ssh -X dinh@192.168.1.137 dinh@192.168.1.137's password: Last login: Fri Aug 21 11:55:47 2015 from 10.237.102.38 /usr/bin/xauth: creating new authority file /home/dinh/.Xauthority [dinh@arrow ~]$ xclock Warning: Missing charsets in String to FontSet conversion ^C
However, sudo to another user and X-Windows breaks.
[dinh@arrow ~]$ sudo su - oracle [sudo] password for dinh: [oracle@arrow ~]$ xclock X11 connection rejected because of wrong authentication. X connection to localhost:10.0 broken (explicit kill or server shutdown). [oracle@arrow ~]$
Work Around:
Just list the xauth.
[dinh@arrow ~]$ xauth list arrow/unix:10 MIT-MAGIC-COOKIE-1 8dfb6c468329ff0d5f5d962b094a82d3
Magic is here.
[dinh@arrow ~]$ xauth list | grep unix`echo $DISPLAY | cut -c10-12` > /tmp/xauth [dinh@arrow ~]$ sudo su - oracle [sudo] password for dinh: [oracle@arrow ~]$ xauth add `cat /tmp/xauth` xauth: creating new authority file /home/oracle/.Xauthority [oracle@arrow ~]$ xclock Warning: Missing charsets in String to FontSet conversion ^C
BINGO!
