ARCHIVED: In the X Window System, how do I display a program running on a remote host?

This content has been archived, and is no longer maintained by Indiana University. Information here may no longer be accurate, and links may no longer be available or reliable.

Assuming you have compatible versions of SSH on both your computer and the remote host, using the X Window System to display a program running remotely is fairly straightforward. From an xterm terminal, use the following syntax:

 ssh -X -f username@remote.host "command"

Replace username and remote.host with, respectively, your username on and the address of the remote host you want to run the program from. Replace command with the name of the X client you want to run. In some cases, the -X option will not be necessary. For example, to run an xterm terminal from the host vader.empire.gov with the account dvader, you would enter:

 ssh -X -f dvader@vader.empire.gov "xterm"

When you use SSH to display the program, it creates a dummy X server on the remote host that forwards the X11 data packets through a secure connection to your computer. The X server on your computer treats the program as if it is running locally.

Note: Pay attention to what version of SSH is installed on both your computer and the remote host. Servers that run version 1 of the SSH protocol cannot communicate with clients that can only use version 2. Likewise, many SSH version 2 servers will refuse clients communicating with version 1 of the protocol, due to security concerns.

If you do not have an SSH client or there is no compatible SSH server installed on the remote host, it may still be possible to run programs remotely. Follow the instructions below:

Note: This alternative method is not secure, and thus is frequently not available. The UITS central systems at Indiana University, for example, do not allow it.

  1. Make sure the remote host is added to the list of hosts that are permitted to display client programs on your monitor. To do this, in xterm, enter:
     xhost hostname
    Replace hostname with the name of the remote host.
  2. Log into the remote host and set the DISPLAY variable on that host to the name of the local host (i.e., the computer with the monitor on which you wish to see the program). If you are using sh, ksh, or bash, you would do this by entering:
     DISPLAY=host:0.0 ; export DISPLAY
    If you are using csh or tcsh, then enter:
     setenv DISPLAY host:0.0
  3. Start the application, and it should appear on your display.

In these examples, host is to be replaced with either the IP number or the hostname of the local host (i.e., your workstation). For example, if you use tcsh, are logged into rebel.net, and want to run Emacs in a window on a workstation whose name is vader.empire.gov, you would enter:

 setenv DISPLAY vader.empire.gov:0.0

The change in the DISPLAY variable will take effect for any X program you run from that shell during that session.

Alternatively, you can control the display of each individual X program by specifying the local host on the command line using the -display option, for example:

 xterm -display host:0.0

By this method, only this program will appear on the given host's display.

At Indiana University, for personal or departmental Linux or Unix systems support, see Get help for Linux or Unix at IU.

This is document adhh in the Knowledge Base.
Last modified on 2018-01-18 10:34:09.