Background
Recently I started working more on linux systems that require X windows to run, mostly due to GUI installers. I am not new to the idea of X forwarding over SSH, and I am not new to the idea that some installers must be run as certain users — But this was a first for me where the graphic installer had to be run on a remote machine, and had to be run as a user with no password.
My Setup
Running Mac 10.9.2 (Mavericks)
Standard Mac Terminal with XQuartz for my X windows display
Steps
Login to your remote server
ssh -X user@remotehost.com
List your xauth
$ xauth list remotehost.com/unix:10 MIT-MAGIC-COOKIE-1 c11dec3114034d20d92e839581bc7a2c remotehost.com/unix:11 MIT-MAGIC-COOKIE-1 ccf459946111123cf8d111cc6795d3e8
If more than one are listed echo your DISPLAY
$ echo $DISPLAY localhost:11.0
Select and copy the correct line
Switch user
$ sudo su - remoteuser [sudo] password for user: remoteuser $
Add the xauth
remoteuser $ xauth add remotehost.com/unix:11 MIT-MAGIC-COOKIE-1 ccf459946111123cf8d111cc6795d3e8
Run your remote GUI app
remoteuser $ ./someLameGUI