Remote access and authentication
Unlike many graphical user interface systems, the X window system was designed with remote access in mind. It is simple to run an X client on one machine and have its windows display and be controlled by an X server running on a different machine.
To work through this section of the tutorial, you will need access to at least two different UNIX machines connected to the same network, with XFree86 installed on both. We will refer to the one you sit in front of as the Server Machine; the other will be called the Client Machine. Although both need to have X installed, only the Server Machine needs to have been configured as described so far in this tutorial. Also remember that you must not have "-nolisten tcp" in your startx script on the Server Machine. The Client Machine must have X libraries installed, but the X server need not be configured or running. In fact, the version of X installed on the Client Machine doesn't even need to be XFree86 -- any modern X implementation will do.
Get server hostname and display number
To get started, open an xterm (or other terminal emulation program) on your Server Machine's desktop, execute the following commands, and note the output. We'll be using this output in the next few steps.
$ hostname servermachine.foo.bar.net $ echo $DISPLAY :0 |
You should already be familiar with the hostname command, but the DISPLAY variable may be new to you. When XFree86 starts up, it takes a display number, usually 0. We'll see how to use this display number in a minute.
Generate a new .XAuthority file
Next, you may have to generate a .Xauthority file, if you don't already
have one. To find out, use the xauth command:
$ xauth list xauth: creating new authority file /home/c/.Xauthority |
If you do not see this error message, and instead xauth lists one or
more authentication lines, then you should skip this next step. An
authentication line looks something like this:
servermachine/unix:0 MIT-MAGIC-COOKIE-1 39849ced20eb2b62df87c714a251b8fc |
If you did see the creating new authority file message,
then you need to generate a new authentication key:
# xauth generate . |
Now, the easiest way to get a remote program's window to show up on your Server Machine's desktop is if your user's home directory is the same on both machines. This is often the case on local UNIX networks when users' home directories are mounted from some central file server via NFS or some other network file system. If this is the case with your Server and Client Machines, all you need to do is tell the Client Machine where to find your X server, covered in the "Set your DISPLAY" section ahead.
Extracting the authentication entry
However, if the two machines do not share your home directory, you'll have to do a bit of work to give your Client the authority to talk to your Server without opening up access to the whole world. To do this, you'll need to copy the authentication entry you created earlier (or one that already existed) to your remote Client Machine. First, you must extract the entry from the Server Machine:
$ xauth nextract myauth.xa $DISPLAY |
Now the file myauth.xa contains your X authentication data; you should be careful not to leave this file lying around were other people can see it, or to transmit it unprotected across public networks. You do need to copy it to your home directory on the Client Machine, so I would recommend using scp (part of the ssh package).
$ scp myauth.xa clientmachine:myauth.xa $ rm myauth.xa |
Merging the authentication entry
Next, log into your Client Machine using rlogin, ssh, telnet, or whatever you normally use to access the other machine. Then, merge your copied authentication entry into the .Xauthority on the Client Machine:
$ xauth nmerge myauth.xa $ rm myauth.xa |
Your Client Machine still needs to know where to find the XFree86 server you are running. Tell it by setting the DISPLAY variable to point to your Server Machine. Make sure you are logged into your Client Machine, and use the hostname and display number you printed earlier. If you're using a Bourne-like shell, do this:
$ DISPLAY=servermachine.foo.bar.net:0 $ export DISPLAY |
Otherwise, if you're using a csh-like shell, do this instead:
$ setenv DISPLAY servermachine.foo.bar.net:0 |
As you can see, we used your Server Machine's name, with the display number tacked on the end.
Now you are ready to run a program on the Client and control it from the Server Machine:
$ xeyes |
You should now see a large pair of eyes (with an unhealthy interest in your mouse pointer) pop up on your screen. This program is running on a remote UNIX box (your Client Machine), and yet is interacting with your mouse and display on your local workstation (your Server Machine). To make xeyes stop, just quit the xeyes program that's running on the Client Machine by typing Ctrl-C in the terminal emulator window. The eyes will then immediately disappear from the display on your Server Machine.
You have now seen most of the many facets of XFree86 configuration. You've worked with several different configuration files (XF86Config, startx, xinitrc, .Xresources, .Xauthority). You've changed remote access and authorization settings, and gotten XFree86 driver settings set up correctly. You should now have the tools you need to take control of your X windowing environment and master your UNIX desktop experience.

