Consultant Life is Hard ep. I – Get that damn SSH X11 forwarding tunnel to work

This is probably more of a note to myself than anything else, since every time I have to do some sneaky X11 forwarding (e.g. to profile or perfomance tune a production server) it somehow never works the first time…having to waste at least 15, fundamentally boring, minutes to figure it out again.

Of course prerequisite is that you need to have some kind of X11 server running on your client, whose display will be forwarded to the server. Linux has it by default, Mac users can install it from the OS disks, for Windows users I suggest XMing to avoid the whole CygWin download).

So this is Gab self reminding recipe for that (tested from MacOS 10.6.8 to RHEL5):

  1. Make sure that
    "X11Forwarding Yes"

    is in your

    /etc/ssh/sshd_config

    on the SERVER SIDE

  2. Make sure that
    "ForwardX11 yes"

    is your

    /etc/ssh_config

    (or

    /etc/ssh/ssh_config

    for Linux distros) on the CLIENT SIDE

  3. Login to the machine with
    ssh -X user@host
  4. If “echo $DISPLAY” does not display any meaningful value (e.g. host:display) then you typically miss libraries on the server side. From root or sudo your should issue at least (this worked for me on all RedHat based distros):
  • yum install xorg-x11-xauth
  • yum install libXtst
  • yum install libXi

At that point you might have to logout/login but the you should be able to run whatever X based application (e.g. JConsole, JProfiler, can you tell I use Java? :)) directly from the server and see the UI pop up on your client.

Never forget anymore Gab…and thanks for reminding to write this down my friend 🙂