How to connect to remote X-Server (logged in via ssh)

46,458

Solution 1

I found the problem. Setting DISPLAY manually to localhost:0 is not working, because the XServer does not listen to TCP connections (default Ubuntu 10.04 configuration).

However, setting

export DISPLAY=:0

does the trick.

Solution 2

You will need to set your display environment variable in the ssh session. Most likely, the X server is running on display 0. So in the ssh session (assuming a Bourne-like shell), type:

export DISPLAY=localhost:0
xclock

You should see the clock on the remote X server display.

Note: this should "just work" if your ssh session is logged in as the same user that started the desktop session on the X server. If you are logged in as a different user, you may need to obtain the xauth cookie from the desktop session's user account.

Solution 3

If you are using the command line ssh, and assuming you are using Linux:

ssh -X host

Then try something like:

xclock

And you should see a clock but it is being ran on the remote computer.

Note: This will only work if x forwarding is turned on in the sshd config file.

Of course this is just a quick overview - can you post more info like what OS you have and what SSH client you are using?

Share:
46,458

Related videos on Youtube

Arathi Arumugam
Author by

Arathi Arumugam

Updated on September 17, 2022

Comments

  • Arathi Arumugam
    Arathi Arumugam over 1 year

    When I'm logged on to another host (e.g via ssh), how do I connect to the XServer of that machine (same user is logged in and is running a desktop (gnome))?

    You may ask way I wish to do that: There are commands that don't open an X-Window, e.g. xinput, xhost, etc.. and there are situations where you want to run them from remote.

  • Arathi Arumugam
    Arathi Arumugam almost 14 years
    Sorry, but I don't need X11 forwarding. If I would ran ssh with X11 forwarding and I enter xinput, I 'll get the list of the x-input-devices of my LOCAL computer, but I want to get the ones from the remote.
  • Cerin
    Cerin over 2 years
    Invalid MIT-MAGIC-COOKIE-1 keyUnable to connect to X server