How to use X11 Forwarding through SUDO

login as:

login as: ec2-user

Authenticating with public key "imported-openssh-key"

Last login: Wed Jul 17 13:44:52 2019 from xxx.xxx.xxx.xxx

ec2-user@ip-xxx-xx-xxx-xx:~>

ec2-user@ip-xxx-xx-xxx-xx:~> echo xauth add `xauth list ${DISPLAY#localhost}`

xauth add ip-xxx-xx-xxx-xx/unix:11 MIT-MAGIC-COOKIE-1 1eec23e7f872c3c34eb129b93261fe54

ec2-user@ip-xxx-xx-xxx-xx:~> echo $DISPLAY

localhost:11.0

ec2-user@ip-xxx-xx-xxx-xx:~> sudo su -

ip-xxx-xx-xxx-xx:~ # xauth add ip-xxx-xx-xxx-xx/unix:11 MIT-MAGIC-COOKIE-1 1eec23e7f872c3c34eb129b93261fe54

ip-xxx-xx-xxx-xx:~ # export DISPLAY=localhost:10.0

ip-xxx-xx-xxx-xx:~ # xclock



Comments