In addition to merely stating the correct command line, I’d like to add a a few things about tunneling (forwarding) X11 connections via SSH:

  • Do not use xhost +. Since you are using SSH, this gives absolutely no benifit, while creating a huge security hole.

  • Do not set the DISPLAY on the remote host. SSH takes care of that for you, and setting it actually breaks the SSH forwarding.

  • You should set up public key authentication, or type your password when prompted. Putting your password on the command line makes it visible to anybody running ps, which defeats the purpose.

Run the command

ssh -X user@remotehost /path/to/x11/program

This will prompt you for the password (unless you have public key auth set up.) If you haven’t already connected via SSH (which you should do before trying to get X11 working), it will also ask you to accept the remote host’s public key.

It really is that simple. To make the command line even less complicated, you can add an entry for the remote host in your ~/.ssh/config:

Host remotehost
	ForwardX11 yes
	User remote_user_name
	Hostname real_host_name_or_ip_address

The Host name can be anything you want, such as an alias or nickname for the machine, it’s just something to identify the set of preferences. If you use the real host name of the remote machine, you can omit the Hostname entry.