Ssh tunneling a local display to another server

port-forwardingsolarissshssh-tunnelingx11

I have a GUI test stand simulation connected to some hardware that is under test. The test stand is a Sun Sparc Ultra 2 SunOs 5.7. The simulation software checks to see if your running your display on :0.0. If not it won't apply power. We do not have the source to re-write the simulation to not check this. I have a need to "See" what is being displayed on the local terminal. I have tried x11vnc but it seems that Xsun might not support the record extension. SSH -X sets the DISPLAY to :10.0 so that is out. I really need to port forward the 6000 port to the say the 6001 port on my windows box running cgwin. (I am assuming 6001 is :1.0 and is what my x server on my windows box will be listing too). Is any of this possible I am at whits end.

Here is the offending code.

/* Console can always access the HW */
if (xserver != (char *) NULL)
{
    /* if the first two characters are ":0" */
    if ((xserver[0] == ':') && (xserver[1] == '0'))
        termtype = TERMINAL_LOCAL;
    else if (uname(&utshost) == 0)
    {
        nnlen = strlen(utshost.nodename);
        if ((int) strlen(xserver) >= (int) (nnlen + 2))
        {
            if ((strncmp(xserver, utshost.nodename, nnlen) == 0) &&
                    (xserver[nnlen] == ':') && (xserver[nnlen + 1] == '0'))
                termtype = TERMINAL_LOCAL;
            else
                termtype = TERMINAL_REMOTE;
        } /* END if */
    } /* END if/else */
} /* END if */

I get this when running xdpyinfo -queryExtensions (truncated for relevancy):

name of display:    localhost:0.0  
version number:    11.0  
vendor string:    The Cygwin/X Project  
vendor release number:    11001000  
maximum request size:  16777212 bytes  
motion buffer size:  256  
bitmap unit, bit order, padding:    32, LSBFirst, 32  
image byte order:    LSBFirst  
number of supported pixmap formats:    7  
supported pixmap formats:  
    depth 1, bits_per_pixel 1, scanline_pad 32  
    depth 4, bits_per_pixel 8, scanline_pad 32  
    depth 8, bits_per_pixel 8, scanline_pad 32  
    depth 15, bits_per_pixel 16, scanline_pad 32  
    depth 16, bits_per_pixel 16, scanline_pad 32  
    depth 24, bits_per_pixel 32, scanline_pad 32  
    depth 32, bits_per_pixel 32, scanline_pad 32  
keycode range:    minimum 8, maximum 255  
focus:  window 0x200023, revert to PointerRoot  
number of extensions:    22  
    BIG-REQUESTS  (opcode: 132)  
    Composite  (opcode: 146)  
    DAMAGE  (opcode: 147, base event: 90, base error: 149)  
    DOUBLE-BUFFER  (opcode: 138, base error: 138)  
    DPMS  (opcode: 139)  
    GLX  (opcode: 148, base event: 91, base error: 150)  
    Generic Event Extension  (opcode: 128)  
    MIT-SCREEN-SAVER  (opcode: 133, base event: 82)  
    RANDR  (opcode: 143, base event: 88, base error: 146)  
    RECORD  (opcode: 137, base error: 137)  
    RENDER  (opcode: 142, base error: 141)  
    SGI-GLX  (opcode: 148, base event: 91, base error: 150)  
    SHAPE  (opcode: 129, base event: 64)  
    SYNC  (opcode: 134, base event: 83, base error: 133)  
    X-Resource  (opcode: 145)  
    XC-MISC  (opcode: 136)  
    XFIXES  (opcode: 141, base event: 86, base error: 139)  
    XFree86-Bigfont  (opcode: 140)  
    XINERAMA  (opcode: 144)  
    XInputExtension  (opcode: 130, base event: 65, base error: 128)  
    XKEYBOARD  (opcode: 135, base event: 85, base error: 136)  
    XTEST  (opcode: 131)  
default screen number:    0  

When I ssh name@server.com The $DISPLAY is servername:0.0 which is local but I can not see.
When I ssh -X name@server.com The $DISPLAY is localhost:0.0 which my simulation sees as remote.

Best Answer

If the simulation software really checks that the display number is 0, you can arrange for your remote display to be 0. Make sure you're not running Xsun locally or run it on a different display (e.g. Xsun :1). In the OpenSSH server configuration file /etc/ssh/sshd_config, add the line X11DisplayOffset 0.

If you connect over ssh, the DISPLAY environment variable will be set to localhost:0.0 (having set X11DisplayOffset as above). This is (for all practical purposes) synonymous to localhost:0 which your application accepts, so you can put this in your .profile:

DISPLAY=${DISPLAY%.0}

If the simulation software wants a local display :0, you can try running it in Xvfb (virtual framebuffer X server, I don't know if it's shipped with Solaris). As above, don't run an X server locally on display :0, run it on :1 if at all. With Xvfb, you can't connect to the display easily, but you can see stills of the screens.

Xvfb :1 -screen 0 1024x768x16 -fbdir /tmp &
DISPLAY=:1 simulation-program &
xwud -in /tmp/Xvfb_screen0

Alternatively, you might try an X server that displays in a window, such as Xnest, Xephyr or VNC — again, if you're running a local X server at all on the Sun machine, run it on display :1. For example, with VNC:

vncserver :1

and you can even connect to that server with a VNC viewer on your Windows machine.

Related Question