Skip to content

Display X After User Switch

Sometimes you find yourself having to redirect the X display to a different host but "ssh -X hostname" will not work since you had to switch users. For instance you logged to a host as root and afterwards "su - oracle".


$ ssh -X
# echo $DISPLAY
# xauth list  MIT-MAGIC-COOKIE-1  95e4b887f2f6d132897aedbbbe297309
host1.domainom/unix:10  MIT-MAGIC-COOKIE-1  961e9e854127e3c70ff8804a5eb57f7e
# su - oracle
$ xauth add  MIT-MAGIC-COOKIE-1  961e9e854127e3c70ff8804a5eb57f7e
xauth:  creating new authority file /home/oracle/.Xauthority

Then trying xclock or xterm worked for me.  If you still have a problem also try:

$ export DISPLAY=localhost:10.0
Published inLinuxSecurity