These classnotes are depreciated. As of 2005, I no longer teach the classes. Notes will remain online for legacy purposes

UNIX01/Accessing X Remotely

Classnotes | UNIX01 | RecentChanges | Preferences

As we have seen, X Windows runs in a client/server model. So you can connect to an X server remotely and run X applications from it on your local machine. All that is required is to have some X Window compliant software running on your machine.

The standard means by which you authorize remote X connections on your local machine is to use the xhost command.

xhost has a very simple interface:

 xhost {-/+} [hostname...]

You add some host, remote.host.com, to your authorized list using the command:

 $ xhost +remote.host.com

You can then later on remove that host from your authorized list using the command:

 $ xhost -remote.host.com

If no host arguments are given, xhost simply returns information about whether authorization exists. For example:

 $ xhost
 access control enabled, only authorized clients can connect

indicates that access control is enabled and there is no authorization list. If, however, we do have access control enabled for a couple of hosts, this is what we would see:

 $ xhost
 access control enabled, only authorized clients can connect
 INET:fresnel.physics.arizona.edu
 INET:einstein.physics.arizona.edu

You can also enable X authorization globally by simply typing

 $ xhost +

This would allow any and all X connections to connect locally. This is a very dangerous thing to do as it opens up many security holes (especially if you are logged in as root user). We will examine in more detail how this can be abused in UNIX03, but for now, trust me, it is not something you want to do.

If you have issued an xhost +, then simply typing xhost will print

 $ xhost
 access control disabled, clients can connect from any host

DISPLAY Environmental Variable

When you are connected remotely to a machine, and wish to make X connections locally with that machine, the environmental variable to set is DISPLAY. The format is as follows:

 DISPLAY = remote.machine.com:X.Y

where X.Y is the local machine's X server terminal information. If you are running X locally, this number is usually "0:0".

Thus, if I were telnetting in remotely and wished to connect to X, the steps involved would be

 localhost $ xhost +remotehost
 localhost $ telnet remotehost
 <log in>
 remotehost $ DISPLAY=localhost:0.0
 remotehost $ export DISPLAY
 remotehost $ <start some X app>

Note that if you are using SSH as opposed to something else, then SSH will tunnel your X connection back across it's encrypted link. So you should not need to export and set DISPLAY remotely (however, you may still need to set xhost locally).



Classnotes | UNIX01 | RecentChanges | Preferences
This page is read-only | View other revisions
Last edited August 2, 2003 3:05 pm (diff)
Search:
(C) Copyright 2003 Samuel Hart
Creative Commons License
This work is licensed under a Creative Commons License.