ssh with X window

I recently found a very useful trick for when I need to run a GUI application, however the device that I would like to run it on, my connection is through SSH.

X11 has to be working on the device for this to work in the first place for it to run. I have tried this method with a number of GUI applications including configuring authentication procedures (LDAP) or Firefox.

I find this a much better and faster process than having to open up VirtualBox to use a GUI application.

To enable the X11 daemon through ssh, run the SSH client with the following flag:

$ ssh -X [email protected]

This will enable you to use and open GUI applications during your session. However a trick I found is putting the actual process in to the background. This means you get your cursor back and you’re able to run further commands while working on the GUI window:

<[email protected]> $ Firefox

The above command will open up Firefox while sending the job in to the background allowing you to carry on work on the machine without having to create new sessions.

You may want to carry on using the terminal session you have logged in while using the GUI application. By sending the process to the background, the cursor is available to utilize. The process can be sent to the background by adding a & to the end of it the line.

<[email protected]> $ Firefox &

Below is an example of a Firefox window opened during a remote SSH session:

n.b. because the Firefox process has been sent to the background, even when the GUI Firefox window is closed, the process hangs in the background. This may cause issues when trying to close the shell session, having the shell hang until the process is stopped using ctrl+c.

Leave a Reply

Your email address will not be published. Required fields are marked *