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.
[email protected]$ ssh -XC server [email protected]$ xauth list [output] [email protected]$ sudo su - otheruser [email protected]$ xauth add [paste output from "xauth list"] [email protected]$ xterm (or other X application)
For x11 on a non-linux OS: