Connect Remotely Using a X Windows Application to UNIX


When connecting remotely to a UNIX system from a PC, Mac, or other UNIX system, you may wish to display X Windows applications on your local computer. To do this, you need to have an X Windows display manager with an access control program on the local computer, as well as a proper setup for the X Windows forwarding from the remote system to the local system. To do this, the local system needs to be running an X Windows server (display manager); the remote UNIX host has the X Windows client application.

The University of Maryland's (UM) UNIX systems (Sun and Linux hosts) and newer Mac systems (including the TerpConnect Macs) have an X Windows server installed as part of the operating system. Some Macs and all Windows PCs do not have an X Windows manager as part of the operating system; it will have to be installed prior to running remote X Windows applications successfully. On Mac OS X, the X Windows component is a part of the extended operating system; it may need to be explicitly installed from the Xcode2 (or Xcode, for older versions of OS X) developer tools. There are several X Windows display managers available for Microsoft Windows, both free and for a cost. 

When you wish to connect from a local PC/Mac/UNIX host to a remote UNIX system, you must do two things before applications running on the remote host can be displayed on the local host:1) you must allow the remote host to display windows on the local host (access control), and 2) you must tell the remote host where to display those windows (display name).


Access Control

The simplest way to provide access control to the remote host is to use the xhost program, which maintains a list of remote hosts that are allowed to make connections to the local X server. To add a host to the access list, use the syntax:

  xhost  +remote_host

where remote_host is the hostname of the remote UNIX system. You can allow multiple remote hosts display access to your local system. To remove a host from the access list, use the syntax:

  xhost  -remote_host

To list which remote hosts are in the access list, simply type xhost, this will tell you if access control is currently enabled, and if so, which hosts are allowed access to the local display.

Note: On the Division of Information Technology Computer Lab Macs, you may need to specify the complete path to the xhost command:

  /usr/X11R6/bin/xhost  +remote_host


Local display


On the remote system, you must define it where to display the X Windows application prior to running it. This is done by setting the DISPLAY environment variable. The syntax to do this varies depending upon which login shell you're using on the remote host:

  csh/tcsh:     setenv  DISPLAY  local_host:0
  sh/bash/ksh:  DISPLAY=local_host:0; export DISPLAY

(Note that "DISPLAY" is all caps.) Once you've added the remote host to the access control list and correctly specified the local display, you should be able to run X applications on the remote host and have them display on the local host.

Note: You can skip the DISPLAY step above if you are using the ssh program with the "-X" option to connect to the remote host. This will automatically enable X forwarding to the local display:

  ssh  -X  remote_host

For further information, refer to the UNIX online documentation:

  man  xhost
  man  ssh