Displaying X programs on remote systems

6,165

If you want to run the X apps over your ssh session you just need to tell ssh to carry the traffic. Don't run xhost and don't override DISPLAY.

ssh -Yf remote-host some-x-application

The -Y flag tells ssh to create a DISPLAY environment variable on the remote-host and carry the resulting traffic across the encrypted connection. The -f flag tells ssh to do all this in the background so that it looks like the session has terminated immediately.

If you prefer to have an interactive shell visibly running on the end of the ssh connection you can also do this sort of thing:

ssh -Y remote-host
...log in as necessary...

some-x-application &
another-x-application &
...etc...

wait; exit
Share:
6,165

Related videos on Youtube

user53029
Author by

user53029

Updated on September 18, 2022

Comments

  • user53029
    user53029 almost 2 years

    I have Ubuntu 14.04 and Fedora 20 as a test environment. I am trying to send X programs from Fedora to Ubuntu through an SSH session. My setup is as follows:

    On Ubuntu ran:

    Xhost +IP Address of Fedora
    

    This returns:

    10.10.24.153 being added to access control list
    

    From the Fedora system I then run:

    DISPLAY=10.10.25.168:0.0
    

    This step redirects Fedora's Display to the Ubuntu system.

    Then I ssh to Fedora from Ubuntu. At this point when I try to launch a program, such as gedit from the ssh prompt I get this: (and no gedit window appears)

    Unable to init server: Could not connect: Connection refused (gedit:7358): Gtk-WARNING **: cannot open display:
    

    HOWEVER, when I launch gedit directly from Fedora it appears on my Ubuntu system, albeit errors on the Fedora side:

    ** (gedit:7372): WARNING **: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-77RFAr0MHI: Connection refused
    

    I should be able to launch the X based program from the ssh session and it appear on screen. Anyone know what I am doing wrong?

  • user53029
    user53029 almost 9 years
    Ok, that works, but is not exactly what I was hoping for. And actually, after re-reading the documentation I was following earlier, It does appear that I have to start the X app on the remote side first, which seems somewhat counterintuitive :/ but thanks for the tip!
  • user53029
    user53029 almost 9 years
    From the ssh or telnet session on the "client/local" side. Use case being I have a low end system that can connect remotely to a server class system and consume its resources rather than mine for running apps however like I said after re-reading the documentation I think the app must be started from the "remote" side.
  • roaima
    roaima almost 9 years
    @user53029 that's exactly what you do. Log on to the client. ssh to the server and run your application.
  • user53029
    user53029 almost 9 years
    I understand. However if I run ssh -Yf <remote host> /usr/bin/firefox or whatever it brings the browser over but then closes the connection. Is there a way to keep it open and run more apps if needed or do I just keep starting up ssh tunnels? I am not aware of a way to do this with SSH which is why I was hoping the "xhost/display" method would work for me.
  • Rk_thenewprogrammer
    Rk_thenewprogrammer almost 4 years
    Don't override DISPLAY = GENIUS. Slams head on table and goes to sleep. Finally got it working.