How do I forward a remote GUI app to localhost as root without login to server as root?

For the obvious security reason that I didn’t want to login to a remote server as root. At the same time, the GUI based app required me to run as root. So, I first ran ssh -X non-root_user@server command as usual. Then I ran “su” command without the dash “-” before I started the GUI based app.

First, the “-X” option allowed me to forward any GUI based app to the machine that initiated the ssh connection, typically localhost. In another words, this option me feel as if I was working on the machine keyboard and monitor directly. After a successful login, any GUI based I ran from the command line would pop-up on my screen. SSH took cares the display forwarding with “-X” option.

Next, “su” without the dash “-” command allowed me to switch user without that user’s environment configuration. I didn’t specify a user name. So, su command assumed I wanted switch to root. The dash “-” allowed me to pick-up all the environment variables configured for that user. For this case, I didn’t because it would remove all the environment config that SSH -X setup for me. So, without the dash “-” enabled me to retain the ability to forward GUI based apps without the need to replicate the forwarding configuration manually.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s