Open a program from one linux box on another boxes screen

How cool would it be to be able run a program from your main computer, but have the window for it come up on say, your laptop while you’re sitting on your bed? Thats what I do.

My main problem is that I can’t get internet on my laptop at home. I’m on dialup and my external modem only connects by serial, which my laptop doesn’t have. Problem.

Solution. I can ssh into my main box which has the modem, connect it to the net and run firefox and it will open it on my laptop screen, using the network. This is a built in feature of X, the display manager for linux.

This HOWTO assumes the following:

  1. You already have ssh setup on the main box
  2. The main box is called serj with an IP of 10.0.0.1
  3. The other box is called malakian with an IP of 10.0.0.4

Here’s how ya do it:

  1. Open up a console window
  2. Add the other box to your X “allow” list by typing the following:
    xhost serj


  3. Find out your display number and remember it (lets say it is 1). Type:
    echo $DISPLAY


  4. SSH into your main box from the other box
    ssh serj -l <em>username</em>


  5. Once you’ve logged in, you need to edit the DISPLAY variable to be the IP and display number (1) of the box you’re on and export it:
    DISPLAY=10.0.0.4:1; export DISPLAY


  6. Once you’ve done that check that it is set properly by echo’ing the DISPLAY variable again. It should show 10.0.0.4:1
    echo $DISPLAY
  7. Now simply run a program like firefox from the command line and the window will open on your box:
    firefox

When you run a program it will open with all the settings from your main box. Unfortunately it won’t work with 3D games but there are a few things it could be useful for e.g.:

  1. Administering one of your screenless servers through an actual GUI (provided you installed with KDE/gnome/some other window manager)
  2. Opening dirty sites on your friends/workmates PC. Open a console, set your display to your workmates IP/display and run
    firefox http://nastyjapanesegirls.com

    . Of course it will be running of your profile so he won’t get done for porn if you do this at work… you will.

There is one draw back though, all sound will run on the main box.

Tags: , ,

Leave a Reply