Lewis' Blog Tales from the trenches of information technology

2Mar/101

Running remote X sessions against old Linux distros

Download PDF

I had occasion last evening to connect to a Red Hat 5.2 server. No, Not Red Hat Enterprise Linux 5, but Red Hat 5.2, as in, before Fedora.

I built the server for a client when 5.2 was the current release of Red Hat, on a Compaq Proliant 1850R server with dual Pentium II's and 512MB(?) RAM in July of 1999. The only hardware replacements on that machine have been a cooling fan (recently) and one of the redundant power supplies (several months ago). Frankly, it was supposed to have been decommissioned quite a while back, but somehow, we just never got around to it, and as it keeps doing what it needs to do, and the need for the single app which it hosts has been dwindling, it just hasn't been bumped up the list.

At the client's location, we have been plagued recently with some rather nasty power outages, prompting us to increase UPS capacity. We currently have two APC 3000VA XL units in the rack, along with a 2200VA unit. The two 3000's have network management cards in them, and the NetWare cluster and W2K3 Citrix server are configured using APC's Network Shutdown software.

Unfortunately, there is nothing currently available from APC which will run on a 2.4 Linux kernel (please someone, correct me if I am wrong in this regard), and when I attempted to build apcupsd on it, I was thwarted by some outdated libraries (and updating libraries on an 11-year-old Linux distro is a very difficult process). As the machine already had APC's PowerChute 4.5.1 for Linux installed on it (2001), I figured I'd just tweak the settings and cable the server to the UPS via serial.

Naturally, I wanted to have a look-see at the xpowerchute GUI.

I rarely run X sessions on that box for a number of reasons: 99% of what runs on it is non-graphic; typically, I access it remotely, via telnet over a VPN connection; and in 1999, window managers weren't quite what they are now (at least, not on Red Hat). In fact, when I first installed that server, I only installed basic X (no Gnome or KDE), and the default window manager is fvwm2.

So, how to go about connecting to a remote X session from a client running openSUSE 11.2?

I can't remember everything, and truth be told, in 1999, I was a relative newcomer to Linux (though I had an appreciation for it, through my daily use of OS/2 since version 2.0 in the early 90's). Some googling pointed me in the right direction, and as all hackers know, once sent in the right general direction, it's usually just a matter of time before cracking the egg.

On the server side:

First, I knew I needed xdm set up to accept connections from my local machine. For security's sake, it is normal to run remote X session via ssh, as in ssh -X, but in this case, behind an Astaro firewall, I wasn't concerned about the lack of encryption from my telnet session.

Remember that xdm simply provides a graphical login from a remote X client. So, on the server side, I needed to tell xdm to present that graphical login to my openSUSE 11.2 box. I added a hosts entry for my box, and then added the following to /etc/X11/xdm/Xserver:

myclient:1 foreign

which tells xdm to present itself to my client machine on display 1 (I was already running an Xserver on my openSUSE box on display 0), and that this client is a remote (foreign) machine.
once making that change, I just needed to start xdm from a prompt, though I used a nice script which I stored in /etc/rc.d/init.d, which I named rcxdm, and gleaned from Linux Online:

#!/bin/sh
# xdm start/stop script for RedHat based systems
#
# chkconfig: 234 60 60
# description: xdm permits remote users to logon to this X display
# processname: /usr/X11R6/bin/xdm
# config: /etc/X11/xdm/xdm-config

# source function library
. /etc/rc.d/init.d/functions

[ -x /usr/X11R6/bin/xdm ] || exit 0

prog=/usr/X11R6/bin/xdm

RETVAL=0

start () {
	echo -n $"Starting $prog: "
# start daemon
daemon $prog
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/xdm
return $RETVAL
}

stop () {
	echo -n $"Stopping $prog: "
killproc $prog
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/xdm
return $RETVAL
}

restart () {
	stop
start
RETVAL=$?
return $RETVAL
}

# See how we were called.
case "$1" in
	 start)
start
;;
 stop)
stop
;;
 status)
status $prog
RETVAL=$?
;;
 restart)
restart
;;
 condrestart)
# only restart if it is already running
[ -f /var/lock/subsys/xdm ] && restart || :
;;
 reload)
echo -n $"Reloading $prog: "
killproc $prog -HUP
RETVAL=$?
echo
;;
 *)
 echo $"Usage: $0 (start|stop|restart|condrestart|reload|status)"
 RETVAL=1
esac

exit $RETVAL

 

Once I started xdm on the Red Hat box:

/etc/rc.d/init.d/rcxdm start

it was a relatively simple matter to get my client session started.
On the client side:

I switched to the first console (Ctrl-Alt-F1, for those not familiar with switching consoles in Linux), and simply typed:

X :1 -query hostname

to tell my local box to start an X server on display 1, and to query the remote host (by name, in this case; I mirror their DNS zone on my server, so lookups are easy) for a login prompt.
My display went black, and moments later, I was presented with a white box in the middle of the screen, proudly displaying the hostname of the remote Red Hat 5.2 server and a login/password dialog. Upon logging in, I was presented with the familiar fwdm2 (stark) desktop and a running xterm. From the xterm, I switched to the /usr/lib/powerchute directory and entered ./xpowerchute, and after a reasonable delay (given the processing power on the other end of the wire and the delay across the WAN link), I was rewarded with the recognizable PowerChute GUI, showing me that the 3000VA XL UPS was online, at 100% capacity, with a run time of approximately 39 minutes, and the current incoming line voltage.

Now, who says you can't teach an old dog a new trick (or two)?

Comments (1) Trackbacks (0)
  1. Many thanks to Alex (Viper007Bond) for his excellent SyntaxHighlighter Evolved plugin, which made it much easier to post this note!


Leave a comment

No trackbacks yet.