X Forwarding Sudo SSH Session
Many environments make use of sudo to delegate access to administrative or application user accounts. This can make ssh X forwarding tricky because your environment changes as you sudo to another user. This is a workaround that will allow you to continue your ssh X forwarding session while running sudo as another user.
How to SSH X Forward Sudo
First you will need a working X11 environment on your local system. There are a number of different options available depending on your OS.
Once you have your local X11 environment working and tested you’re ready to proceed x forwarding sudo.
you@local$ ssh -XC server you@server$ xauth list [output] you@server$ sudo su - otheruser otheruser@server$ xauth add [paste output from "xauth list"] otheruser@server$ xterm (or other X application) |
For more information please refer to the xauth, sudo and ssh man pages.
For x11 on a non-linux OS:
Xming for windows http://sourceforge.net/projects/xming/
Xquartz for OSX http://xquartz.macosforge.org/landing/