I use MobaXterm as my primary terminal client. Besides some excellent features, it has a selling point - the built-in X server. Yet you may still be in a position where you can't just forward your X windows to your local machine and have to make some extra steps.
Some environments are very restrictive on how you access privileged OS accounts, so you cannot use the application owner's account to access the system but only sudo into it. There are plenty of how-tos regarding forwarding X sessions for sudoers. In general, before switching to the user, you should:
- Collect session variable DISPLAY value
- Find out your X session authentication details
- Switch to the new user with sudo su
- Replicate your original X session for the new user environment
To automate and simplify this process I create a small Bash script on all VMs where I may need X session and placed it into ~/bin folder.
Now, if you need only terminal session you switch to the appowner account as usual and use this script if you need to run some GUI-based applications.
Now, anytime before you want to run xclock, copy and execute those two lines from the command output. with the cookie and display details commands.