X11 tunnel over ssh and then rsh

Nikos Vassiliadis nvass at teledomenet.gr
Thu Aug 21 08:48:24 UTC 2008

On Thursday 21 August 2008 09:54:29 Roberto Nunnari wrote:
> Anybody on this, please?
> Roberto Nunnari wrote:
> > Hello list.
> >
> > I have this scenario
> >
> > 1) host A with X server
> > 2) host B with ssh server but without X server
> > 3) host C with rsh server and X client programs but without X server
> > (on host C there's also an ssh server, but in our case, users
> > have to use rsh)

Why rsh? Isn't ssh a drop-in replacement for rsh?

> >
> > now, I need to connect from host A to host B with:
> > A$ ssh -Y B (-Y or -X, to create a X tunnel)
> > and then from host B to host C with:
> > B$ rsh C
> > and on host C I need to run an X client like:
> > C$ xterm
> >
> > Now, I would like the users not to have to set the
> > DISPLAY env var on host C, as they tend to forget
> > and also some user's X server don't accept plain
> > X connections..
> >
> > Is there a way that I could configure host B to somehow
> > expose to host C the X tunnel to host A?

Automatically? No.
You can however use ssh to create generic TCP tunnels, using
-R and -L. But this is much more complicated than remembering
a DISPLAY variable.

> > From host 
> > B I have access to the users' homes on host C and I could
> > place there some script to set the DISPLAY env var on user
> > login.
> >
> > B$ echo $DISPLAY
> > on host B gives back something like localhost:16.0,
> > but if on host C I enter:
> > C$ export DISPLAY=B:16.0
> > C$ xterm
> > it doesn't work.. probably host C doesn't expose a
> > network socket but maybe a unix socket for the X tunnel..

This is probably because the listener (which proxies X11 to
host A) is bound to localhost( and not B(
You can overcome this, using manual forwarding(-R & -L).

HOST_A# ssh -R '*:6010:' HOST_B  # create a listener
	on HOST_B listening on all interfaces and TCP port 6010
	and tunnel everything from there to HOST_A's 6000

Then every host which can connect to HOST_B can connect to HOST_A
X11 server. Using generic TCP port forwarding through ssh to forward
X11 has an other minus. You have to handle yourself the X11 
authorization(xauth, XAUTHORITY and friends)

You can of course use a second ssh session from HOST_B to HOST_C
to expose HOST_B's to HOST_C's
So, connecting from HOST_C to will be tunneled
to HOST_B's, which will be tunneled to HOST_A's were your X11 display lives.

It's rather complicated, though...

More information about the freebsd-questions mailing list