I use ssh on a daily basis for almost all my work (and at home, for managing my linux server), and occasionally have the need to run a X11 program. In that past I have been going through the pain of setting all the variables, on both the remote server and my local machine. I start up my X server, run xhost +ip.addr.ess, and on the remote server, set the DISPLAY variable. This does work fine if you’re on a routable network, but if not there’s a lot more trickery involved.
Finally I took the time to figure out the proper settings for forwarding X11 using ssh – they involve changing both your ssh client config, and the ssh server config, so you’ll need permissions for both ( or ask your friendly sysadmin).
On the server side, you need the following in sshd_config (/etc/ssh/sshd_config on Centos/RHEL/Fedora/etc):
X11Forwarding yes
X11DisplayOffset 10
The first line enables ssh forwarding, and the second sets the X11 display offset to start handing out to ssh clients (i.e. localhost:10).
On the client side, there is the option to change X11 forwarding settings in the global or local config file. I recommend changing settings locally, per server, as this will minimize your security risks – if a malicious user could get access to the display device, he could snoop on all your activity, keystrokes included.
Edit, and create if needed, ~/.ssh/config. Setup per-server entries for each server you want to enable forwarding to, like so:
Host 10.1.2.3
ForwardX11 yes
Host 10.1.2.4
ForwardX11 yes
ForwardX11Trusted yes
All you need is a Host entry, and ForwardX11 yes to get it working. With some applications (java), you will need to add the ForwardX11Trusted line as well, but don’t do so unless you are getting a blank box instead of your application. I needed this for my primary use of X11 forwarding, managing Veritas Netbackup.
linux, osx, ssh, sshd, x11