Remote Graphics

Background

Most users will not need to run graphical applications on a remote Unix system.. If you know that you will need to use a graphical user interface with your research software, or if you want to use a graphical editor such as eclipse or emacs on over the network, read on. Otherwise, you can skip this section for now.

Unix uses a networked graphics interface called the X Window system. It is also sometimes called simply X11 for short. ( X11 is the latest major version of the system. ) X11 allows programs running on a remote Unix system to display graphics on your screen. The programs running on the remote system are called clients, and they display graphical output by sending commands (magic sequences) such as "draw a line from (x1,y1) to (x2,y2)" to the X11 server on the machine where the output is to be displayed. The computer in front of you must be running an X server process in order to display Unix graphics, regardless of whether the client programs are running on your machine or a remote machine.

Apple's macOS, while Unix compatible at the API and command-line, does not include X11 by default. It instead uses Apple's proprietary GUI. X11 for macOS is provided by the XQuartz project: https://www.xquartz.org/. XQuartz is free open source software (FOSS) that can be downloaded and installed in a few minutes. It should start automatically when either local or remote X11 clients attempt to access your display, but you can also start it manually.

Configuration Steps Common to all Operating Systems

Modern Unix systems such as BSD, Linux, and macOS have most of the necessary tools and configuration in place for running remote graphical applications. Some Unix servers may be configured without a GUI. If you want to remotely log into such a server and run X11 programs from your desktop or laptop system, you will need to at least install the xauth package on the remote system. This allows your system to configure X11 permissions for the remote system when you log in using ssh -X or ssh -Y.

# Debian
shell-prompt: apt install xauth

# FreeBSD
shell-prompt: pkg install xauth

# RHEL
shell-prompt: yum install xorg-x11-xauth
        

Some additional steps may be necessary on your computer to allow remote systems to access your display. This applies to all computers running an X11 server, regardless of operating system. Additional steps that may be necessary for Cygwin systems are discussed in the section called “Graphical Programs on Windows with Cygwin”.

If you want to run graphical applications on a remote computer over an ssh connection, you will need to forward your local display to the remote system. This can be done for a single ssh session by providing the -X flag:

shell-prompt: ssh -X joe@unixdev1.ceas.uwm.edu
        

This causes the ssh command to inform the remote system that X11 graphical output should be sent to your local display through the ssh connection. ( This is called SSH tunneling. )

Caution

Allowing remote systems to display graphics on your computer can pose a security risk. For example, a remote user may be able to display a false login window on your computer in order to trick you into giving them your login and password information.

If you want to forward X11 connections to all remote hosts for all users on the local system, you can enable X11 forwarding in your ssh_config file (usually found in /etc or /etc/ssh) by adding the following line:

ForwardX11 yes
        

Caution

Do this only if you are prepared to trust all users of your local system as well as all remote systems to which they might connect.

Some X11 programs require additional protocol features that can pose more security risks to the client system. If you get an error message containing "Invalid MIT-MAGIC-COOKIE" when trying to run a graphical application over an ssh connection, try using the -Y flag instead of -X to open a trusted connection.

shell-prompt: ssh -Y joe@unixdev1.ceas.uwm.edu
        

You can establish trusted connections to all hosts by adding the following to your ssh_config file:

ForwardX11Trusted yes
        

Caution

This is generally considered a bad idea, since it states that every host we connect to from this computer to should be trusted completely. Since you don't know in advance what hosts people will connect to in the future, this is a huge leap of faith.

If you are using ssh over a slow connection, such as home DSL/cable, and plan to use X11 programs, it can be very helpful to enable compression, which is enabled by the -C flag. Packets are then compressed before being sent over the wire and decompressed on the receiving end. This adds more CPU load on both ends, but reduces the amount of data flowing over the network and may significantly improve the responsiveness of a graphical user interface.

shell-prompt: ssh -C -X joe@unixdev1.ceas.uwm.edu
        

Caution

Using -C over a fast connection, such as a gigabit network, may actually slow down the connection, since the CPU may not not be able to compress data fast enough to use all of the network bandwidth.
Graphical Programs on Windows with Cygwin

It is possible for Unix graphical applications on the remote Unix machine to display on a Windows machine with Cygwin, but this will require installing additional Cygwin packages and performing a few configuration steps on your computer in addition to those discussed in the section called “Configuration Steps Common to all Operating Systems”.

Installation

You will need to install the x11/xinit and x11/xhost packages using the Cygwin setup utility. This will install a basic X11 server on your Windows machine.

Configuration

After installing the Cygwin X packages, there are additional configuration steps:

  1. Create a working ssh_config file by running the following command from a Cygwin shell window:
    shell-prompt: cp /etc/defaults/etc/ssh_config /etc
                    
  2. Then, using your favorite text editor, update the new /etc/ssh_config as described in the section called “Configuration Steps Common to all Operating Systems”.
  3. Add the following line to .bashrc or .bash_profile (in your home directory):

    export DISPLAY=":0.0"
                    

    Cygwin uses bash for all users by default. If you are using a different shell, then edit the appropriate start up script instead of .bashrc or .bash_profile. For tcsh, add the following to your .cshrc or .tcshrc:

    setenv DISPLAY ":0.0"
                    

    This is not necessary when running commands from an xterm window (which is launched from Cygwin-X), but is necessary if you want to launch X11 applications from the Cygwin terminal which is part of the base Cygwin installation, and not X11-aware.

Start-up

To enable X11 applications to display on your Windows machine, you need to start the X11 server on Windows by clicking Start All Programs Cygwin-X XWin Server. The X server icon will appear in your Windows system tray to indicate that X11 is running. You can launch an xterm terminal emulator from the system tray icon, or use the Cygwin bash terminal, assuming that you have set your DISPLAY variable as described above.

Remote 3D Graphics

It is possible to run Open 3D graphical applications on remote systems as well, but performance may or may not be acceptable. There are also numerous problems that can arise that depend on the operating system and video drivers used on each end. In any case, OpenGL applications will require additional X11 components to be installed on both the remote machine running the application and the display machine running the X11 server. Determining the minimal set of packages required for every platform would be excessively difficult, so we recommend simply install the entire Xorg system on the remote system. This will likely enable at least some OpenGL applications to run remotely. This proved sufficient to run the 3D mesh visualizer MeshLab comfortably on a remote FreeBSD machine from a FreeBSD display. A similar application called VMD proved too sluggish to use remotely.

# Debian
shell-prompt: apt install xorg

# FreeBSD
shell-prompt: pkg install xorg
        

You may find it easier to simply download the data files to your local machine and run the 3D graphics applications there. Performance will be much better when using direct rendering, where the display is on the same machine running the 3D application. When using indirect rendering, where the 3D application is running on a different machine than the display, sending graphics commands over a network can be a bottleneck.

Practice

Note

Be sure to thoroughly review the instructions in Section 2, “Practice Problem Instructions” before doing the practice problems below.
  1. What is X11?

  2. Does Apple's macOS use X11? Explain.

  3. What must be installed at minimum on a remote computer to allow X11 client programs to run there and display graphics on the X11 display in front of you?

  4. Show a Unix command that logs into unixdev1.ceas.uwm.edu and allows us to run remote graphical programs.

  5. Show a Unix command that logs into unixdev1.ceas.uwm.edu and allows us to run remote graphical programs over a slow network.

  6. Why is setting ForwardX11Trusted not generally a good idea?

  7. What packages are needed on a Cygwin setup to enable X11?

  8. What alternative do you have if running a 3D graphics program remotely proves to be too complicated or slow? How will this help?