unixtips.org

the source for unix tips ...

Running X-Programs on Remote Computers
Scott Parish ([email protected])

The X Window System was designed to be able to run programs on other computer over a network, and have the display shown on your desktop. We are going to explore this and see how easy it is to use.

To do this we need two computer: one that is running an X11 server, and another computer to run the remote program. These computer's must be networked together, and you need to be able to rsh or ssh into the second computer that is to run the program. For the example I am using gawk.wwc.edu to log into olympus.wwc.edu. (gawk is my Linux Workstation running X, and olympus is a Solaris computer that I have an account on, and has several programs that I can not run on my workstation) I am going to log onto olympus and run matlab, which I can not run on gawk due to licensing issues.

For security reasons, before the X Window System will display a window on the X screen, the computer which wants to display the window must be allow to display it. There are two ways to allow a computer to display windows on your screen: xhost and xauth. For now we are going to look at xhost.

Lets start by taking a look at the current xhost configuration. First I am going to open a terminal window in X. Since I like eterm, I run eterm, and receive a window with the following:

gawk:~$ _
At this point I can type xhost, and receive something similar to the following:
gawk:~$ xhost
access control enabled, only authorized clients can connect
INET:localhost
INET:gawk.wwc.edu
INET:gawk.wwc.edu
LOCAL:
gawk:~$ _

This shows that localhost and gawk.wwc.edu show windows on my screen. Both of these names are the referring to my workstation. It is very good that these are authorized by xhost, because this is the computer I am running X on!

I need to authorize olympus access to my display, so I use xhost to add olympus by typing xhost +olympus.

gawk:~$ xhost +olympus
olympus being added to access control list
gawk:~$ xhost
access control enabled, only authorized clients can connect
INET:olympus.wwc.edu
INET:localhost
INET:gawk.wwc.edu
INET:gawk.wwc.edu
LOCAL:
gawk:~$ _ 

Okay, gawk is now already to show matlab when olympus runs it. My next step is to log into olympus, so that I can run matlab. I could use either rsh or ssh, but I choose to use ssh because it prevents people on my network sniffing for my password. So I type ssh, and log on as usual.

gawk:~$ ssh olympus.wwc.edu
[email protected]'s password: ****** 
Last login: Mon Nov  2 22:18:23 1998 from washington.wwc
Sun Microsystems Inc.   SunOS 5.6       Generic August 1997
No mail.
olympus:~> _

Okay, I am logged on to olympus now. We are almost ready to run matlab, but there is still one more thing to be done. If we try to execute matlab it wouldn't run because it would not know where to display the windows it generates. We need to set up the DISPLAY environment variable to use gawk. This Solaris account has me running using the bash shell, so I simply type DISPLAY=gawk.wwc.edu:0.0, and now I can run matlab, or any other program on olympus and everything will be displayed to me at gawk.wwc.edu!

olympus:~> DISPLAY=gawk.wwc.edu:0.0
olympus:~> matlab

So now I have started matlab, and I can go ahead and continue to do whatever tasks I need done with it.

Actually, though, if you are using ssh it should be much easier then that! ssh will automaticly do the xhost and the DISPLAY configuration for you. The reason I went through all of it in the example was so that you would know how to do it by hand, and how to do it with rsh (since you have to set things up by hand with rsh).

What is the point though? How often would you actually want to do this? Actually I do this quite often to run matlab because of the licensing. But there are also further uses like being able use Linux on your workstation, but run Solaris or other Unix programs on your desktop side by side with your Linux applications. Or if you need to run a program that takes a lot of cpu power, it would be much cheaper to buy one really fast computer for everyone who needs to run the program, than to buy each person that super fast computer. You could also run administration programs that require X windows remotely. I will leave you to think of other ways you can use this, but if you think about it, the possilities that this presents are almost endless!

 

About   |   Add tip   |   Articles   |   Categories   |   Links   |   Random   |   Tips


Copyright 1998-2004 Scott Parish and George Lewis.
Send feedback to [email protected].