Search code examples
namespacessocatx11-forwarding

Using socat to access X remotely


I have a remote server on which I want to launch some gui applications inside a network namespace I have already setup. I am using socat to forward the x session.

socat  exec:'ssh {REMOTE_HOST} rm -rf /tmp/.X11-unix/X1; socat -d -d -d -d unix-l\:/tmp/.X11-unix/X1111 -' unix:/tmp/.X11-unix/X0

However, if I try to launch an application like eog

DISPLAY=:1111 eog

It fails with the following message:

I   No protocol specified
** (eog:9498): WARNING **: Could not open X display
Cannot open display:
Run 'eog --help' to see a full list of available command line options.

And socat exits immediately afters.


Solution

  • Well, it took a day but I figured a way to do it.

    I ended up using Xpra to start an X-server at the remote server and attached to it in my local machine.

    The socat approach worked too after running xhost + locally and adding the fork flag in the socat invocation at the remote server . However, it never worked consistently (There was as much chance the application to hang during launch as not). And it never worked with more complex applications like firefox. Stracing the apps pointed towards the applications hanging when trying to use dbus.