Using XWindows remotely

cbrooks on 2002-12-12T14:12:59

As part of my new eternal commute, I have started working a bit from home -- an hour here, an hour there. One of the annoying aspects of this is managing email. If I check company email from home, I either see the same messages twice (once from home and once at work), or I can choose to have the messages deleted from the server as soon as I delete / move them at home. Neither approach is ideal.

My new approach is to have a single mail client located at work. I fire up Cygwin on my Windows box at home, invoke ssh, and interact with Mozilla remotely using X Windows. (Actually, I'm fibbing a little. So far, I have a Linux box at work running my mail client, and I'm just shelling in from my Windows / Cygwin box across the office.) But, it's a neat trick, and it will greatly simplify any future work from home.

Here are the steps that I took, in case anyone is interested in trying something similar.

  1. Get Linux configured on the box that you are going to run your mail client on. (You could also run Cygwin on top of Windows, I suppose.) Make sure that you can use X on this box, and make sure that you have the latest openssh daemon configured and listening to port 22. I suppose you should also make sure that you can access this box remotely over ssh.
  2. Install Cygwin on the Windows box that you will use remotely. (Cygwin, BTW, is free as in speech, and free as in beer for most purposes.) The Cygwin installation process is quite straightforward, once you get used to its somewhat non-intuitive interface. You can download the setup program from www.cygwin.com. I chose to install the following packages (which take up about 250 MB of disk space):
    • All: Default
    • Doc:Man and Texinfo
    • Editors: ed, mc and vim (because vi is the one true editor, okay, the two true editors, because it uses ed under the hood)
    • Net: Openssh and rsync (rsync isn't necessary for this project)
    • Text: more, less
    • XFree86: pretty much everything. Make sure you have fvwm and base
  3. Follow the instructions at www.shadlen.org. I found these to be pretty good, although the startwin.sh script mentioned was actually in /usr/X11R6/bin/startxwin.sh, rather than /usr/X22T6/bin/startwin.sh.
  4. At this point, I was able to shell into the Linux box that would host my mail client. However, when I tried to invoke a utility (such as xclock) that relied on X, I got the following error: "authentication failed - cannot start X server - perhaps you do not have console ownership". I was able to fix that thanks to the following usenet post: http://archives.neohapsis.com/archives/pam-list/2000-10/0064.html.
  5. I made a minor change to my ~/.ssh/config file (on the remote Cygwin box), setting "ForwardX11 yes". (You could also just pass the "-X" option to ssh at the command line.)
  6. From cygwin, I fire up an xterm, and invoke ssh with the following options: "ssh -n ip_addr mozilla", and lo and behold, Mozilla pops up.
I have not been able to launch startx successfully (remotely), though I can launch it on the local box directly. I think that my ssh client is configured correctly, which makes me suspect that the problem has something to do with inadequate libraries on the Cygwin box. (For example, if I shell from the local Linux box back to itself, I can run startx successfully.) I believe this suggests that if the remote box had the correct software, the X11-forwarding would work correctly. Does anyone have any brainstorms?


Hm?

chromatic on 2002-12-12T20:00:08

You want to start an X server on your home machine when you're at work? I don't think it works that way. What are you trying to do?

Re:Hm?

cbrooks on 2002-12-12T20:43:32

I'm not sure which question to answer first. Let's start with this one:

>What are you trying to do?

The goal is to be able to run a single mail client seamlessly from home or from work. That is, I want to have my inbox, sent mail, drafts, etc. all centralized in one place. Imagine, for example, that I used pine to manage my email, and imagine that the server on which that pine account lived was located 2000 miles away from both my work and my home. To handle my mail, I would simply shell into the remote server, and it wouldn't matter whether I do it from work or from home. I want to do the same thing in this scenario, except the mail client that I want to use happens to run on X Windows.

>You want to start an X server on your home machine when you're at work?

Well no, not exactly. Let me start by defining my terms: My office computer is the computer on which I will run my master mail client. My home computer is the computer that I will use while working from home. (I don't want to use the terms "client" and "server", since technically, the X Windows server resides on the home machine in this example, and that detail makes the discussion unnecessarily confusing.) One of the really slick things about X Windows is that you can forward it to a remote machine (over ssh, no less!). So, using the instructions from my previous message, I can fire up cygwin at home, open an encrypted connection to my computer at work, and work directly on my master mail client.

Re:Hm?

cbrooks on 2002-12-18T13:49:05

Perhaps I replied too quickly to this.

Yes, I was misunderstanding a part of the process. Essentially I was firing up a window manager (fvwm2) and then trying to forward a second window manager (sawfish -- RedHat 7.3's default window manager) onto fvwm2 by running "startx". What I need to do is run sawfish on my home machine, and then forward mozilla.



That may, (or may not?) have been the point you were making. ;-)

Re:Hm?

chromatic on 2002-12-18T17:45:14

Yeah, that sounds like the point I was making. :) If you start X on your work machine and just fire up an XTerm, you can log in to your home machine and run sawfish just as any other X client. (sawfish & should do it -- startx does a bit too much.)

mutt!

jbisbee on 2002-12-18T15:02:46

I just stay away from the X clients all together and use mutt. Its extremly powerful and all you need is to ssh into the box to check your mail. You can even try IMAP over SSL so all your mail stays in once place so you don't get duplicate copies and stuff.

Just giving you some other options so you don't have to rely on getting X forwarding working just to check mail. (for example if you visit a friend on vacation and they just have windows 98 and AOL, you just need to grab a win ssh client like putty to log in manage your mail)