Procedure :
i. [ec2-user@10-20-3-40 ~]$ xclock
Warning: Missing charsets in String to FontSet conversion
ii. [ec2-user@10-20-3-40 ~]$ xauth list
10-20-3-40/unix:12 MIT-MAGIC-COOKIE-1 7e53e7600ff4177d7bbc66bde0a1b1ca
10-20-3-40/unix:11 MIT-MAGIC-COOKIE-1 e3d1a8915484c929ef3e809b047e6352
iii. [ec2-user@10-20-3-40 ~]$ env | grep DISPLAY
DISPLAY=localhost:10.0
iv. [ec2-user@10-20-3-40 ~]$ xauth list | grep unix 'echo $DISPLAY | cut -c10-12' > /tmp/xauth
[ec2-user@10-20-3-40 ~]$ ll /tmp/xauth ; cat /tmp/xauth
-rw-rw-r-- 1 ec2-user ec2-user 78 Dec 7 14:47 /tmp/xauth
10-20-3-40/unix:11 MIT-MAGIC-COOKIE-1 e3d1a8915484c929ef3e809b047e6352
v. [ec2-user@10-20-3-40 ~]$ sudo -i
Last login: Fri Dec 7 14:43:12 UTC 2018 on pts/0
vi. [root@10-20-3-40 ~]$ xauth add 'cat /tmp/xauth'
[root@10-20-3-40 ~]$ xauth list
10-20-3-40/unix:11 MIT-MAGIC-COOKIE-1 e3d1a8915484c929ef3e809b047e6352
vi. [root@10-20-3-40 ~]$ env | grep DISPLAY
vii.[root@10-20-3-40 ~]$ export DISPLAY=localhost:11.0
viii.[root@10-20-3-40 ~]$ xclock
Warning: Missing charsets in String to FontSet conversion
Note :
After swtiching it from root to any other user please follow the step vi to step viii
[dinh@securehost ~]$ ssh -X ec2-user@ipaddress
Last login: Fri Dec 7 14:41:41 2018 from gw.ca.adm.pythian.com
__| __|_ )
_| ( / Amazon Linux AMI
___|\___|___|
https://aws.amazon.com/amazon-linux-ami/2018.03-release-notes/
13 package(s) needed for security, out of 16 available
Run "sudo yum update" to apply all updates.
### Test xclock works from ec2-user
[ec2-user@ipaddress ~]$ xclock
Warning: Missing charsets in String to FontSet conversion
^C
### Show all magic cookie
[ec2-user@ipaddress ~]$ xauth list
ipaddress/unix:12 MIT-MAGIC-COOKIE-1 7e53e7600ff4177d7bbc66bde0a1b1ca
ipaddress/unix:11 MIT-MAGIC-COOKIE-1 e3d1a8915484c929ef3e809b047e6352
<strong>ipaddress/unix:10 MIT-MAGIC-COOKIE-1 07b3de3093cef835c19239ea952231b7</strong>
### Show DISPLAY variable
[ec2-user@ipaddress ~]$ env|grep DISPLAY
<strong>DISPLAY=localhost:10.0</strong>
### Create /tmp/xauth based on current DISPLAY variable
[ec2-user@ipaddress ~]$ xauth list | grep unix`echo $DISPLAY | cut -c10-12` > /tmp/xauth
[ec2-user@ipaddress ~]$ ll /tmp/xauth ; cat /tmp/xauth
-rw-rw-r-- 1 ec2-user ec2-user 78 Dec 7 14:47 /tmp/xauth
<strong>ipaddress/unix:10 MIT-MAGIC-COOKIE-1 07b3de3093cef835c19239ea952231b7</strong>
### Sudo to oracle
[ec2-user@ipaddress ~]$ sudo su - oracle
Last login: Fri Dec 7 14:43:12 UTC 2018 on pts/0
### Add and Verify xauth
[oracle@ipaddress ~]$ xauth add `cat /tmp/xauth`
[oracle@ipaddress ~]$ xauth list
<strong>ipaddress/unix:10 MIT-MAGIC-COOKIE-1 07b3de3093cef835c19239ea952231b7</strong>
### Verify and Add DISPLAY variable
[oracle@ipaddress ~]$ env|grep DISPLAY
[oracle@ipaddress ~]$ export <strong>DISPLAY=localhost:10.0</strong>
### Test xclock works from oracle
[oracle@ipaddress ~]$ xclock
Warning: Missing charsets in String to FontSet conversion
^C
[oracle@ipaddress ~]$
### Example of failed xclock
[oracle@ipaddress ~]$ xclock
Error: Can't open display:
[oracle@ipaddress ~]$ xclock