Wednesday, May 12, 2010

X11 Forwarding after sudo

Normally, you can do the following:
ssh -X user@host
However, if you need to su - root after logging in, the X11 forwarding setup by ssh will no longer be valid.
Do the following:
<as user> $ echo $DISPLAY
<note down the value>
<as root> # export DISPLAY=<the value noted earlier>
This will set the proper display. However, the Xauthority will not match. To fix that do the following:
# cp /home/<user>/.Xauthority /.Xauthority 
(or wherever the root home directory is)