SSH and X forwarding

I love SSH, coupled with byobu(an updated GNU screen) it is amazingly powerful.  But sometimes it is really useful to be able to view a GUI application on the remote server end.  Some people think that they need to use VNC to do this.  VNC is terrible, and there is a better way.

Things you will need:

  • An X capable SSH client
    • On Linux you don’t have to worry about this
    • On Windows I recommend MobaXTerm
    • On OS X I think you just need to install something like XQuartz
  • A server that has a graphical environment installed on it
    • Ubuntu Desktop is an easy example
    • Gnome/KDE/XFCE/X11 etc.
  • SSH server installed on the server
  • A GUI application that you want to run over SSH

In my example I’m going to be connecting from a Windows computer, using MobaXTerm, to a Ubuntu Desktop machine, and running WireShark(yes I know about tshark).

Make sure sshd is installed on the Ubuntu machine.

$ sudo apt-get install ssh

Back on the Windows machine, we SSH to the Ubuntu machine. Notice that we are specifying -X which allows us to run X applications over SSH

$ ssh -X username@192.168.1.100

Then we run our application

$ wireshark

And there you have it:
WiresharkOverX

That is Wireshark running on the remote Linux machine.  Notice the GTK/Ubuntu looking buttons, and the Windows colored Window frame.

Thanks for stopping by!

Photo Credit

Leave a Reply