Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

The problem

Most people want to connect to a server over ssh with the "-X" option in order to run GUI programs on the remote host using the display of the client. I would like to run GUI programs on the physical monitor attached to the server. Is this possible ? Let me be more specific:

My situation is the following: I have a workstation without a keyboard or mouse, but it has a monitor connected to it. I would like to SSH to it with my laptop and be able to launch some graphical program, such as xeyes or ssvnc and have it appear on the workstation's monitor.

[xapple@laptop ~]$ ssh workstation
Last login: Mon Sep 26 20:03:35 2011 from laptop
[xapple@workstation ~]$ export DISPLAY=:0
[xapple@workstation ~]$ xeyes
No protocol specified
Error: Can't open display: :0

Edit: extra information

I should maybe explain a few things more clearly:

  • I have sudo access on the workstation, I can install anything if needed.
  • The workstation is running the GNOME user interface.
  • Before disconnecting the keyboard and mouse from the workstation, I logged into a GNOME session. One can therefor see my GNOME desktop on the workstation's monitor currently.
  • I don't wish to run programs from my laptop on the workstation. I would like to run workstation programs on the workstation. The xeyes or whatever executable is found on the remote server and should be run on the remote server's monitor
  • I understand that performing this will leave me in a situation where my cursor will not be connected to the interface. I don't be able to click on things. That's ok.

Any help greatly appreciated !

share|improve this question
    
Did you executed xhost + on your server? –  karlphillip Nov 23 '11 at 13:38
add comment

2 Answers 2

any xlib-application must connect to a xserver. you have to tell the app the connection to the server by either:

  • setting the environment variable DISPLAY
  • using a command line flag such as -display

the first xserver usually can be reached by the connection string ':0'. so, try this:

xeyes -display :0

or this

env DISPLAY=:0 xeyes
share|improve this answer
    
In many cases (such as when started by GNOME's GDM), setting XAUTHORITY will be needed as well, since the X11 server will be using a temporary Xauthority file. –  grawity Sep 27 '11 at 12:35
    
Interesting, after setting the $DISPLAY variable, I now get, in addition to the "Error: Can't open display" message, the "No protocol specified" message when trying to launch xeyes. –  xApple Sep 28 '11 at 9:06
    
@grawity Thanks for the advice. Can I ask how would I set my XAUTHORITY in order for my command to work ? –  xApple Sep 28 '11 at 14:41
add comment

Is this workstation running an X Windows server? Without that, this is all moot.

You need SOMETHING to process the data into graphics, pixels, colors and locations. A 'monitor' is useless without some sort of software to run it.

Assuming it is. (but from the text, sure sounds otherwise)

Given the host names (and appropriate DNS resolution through /etc/hosts or DNS or whatever) of 'workstation' and 'laptop'... if not, replace the machine host names with appropriate IP addresses.

ssh workstation
xhost +laptop

you can then log out of the workstation at this point, as this sets the permissions on the workstation's Xserver to allow 'laptop' to connect.

if you start your programs with the DISPLAY env var set appropriately, you can cause applications to be displayed on the workstation, while running on your laptop.

DISPLAY=workstation:0 xeyes

-or-

export DISPLAY=workstation:0
xeyes

either method will work, the latter causes anything X11 related to be displayed on the workstation when started from that shell. (hope that made sense)

The 'xhost' line is to allow permission for the laptop to connect to the workstation's Xserver. Without it, you'll get permission denied, unless you start the X server with NO permissions, which isn't really recommended. The 'xhost' protection is still lame, as the data is sent 'plain-text' between laptop and workstation and could be sniffed, but it's an easy solution.

If you wanted privacy, you'd need to set up some sort of encrypted tunnel between your laptop and the workstation (port 6000 for display :0). Yup, it gets weird at this point.

If you're in a controlled environment, then using the 'xhost +laptop' command will be sufficient, if you leave of the 'laptop' part of that command 'xhost +', then ANYONE can connect to the Xserver and display things.

Do remember, your mouse is NOT 'connected' to the workstation Xserver, and you will NOT be able to manipulate windows or click on things.

If you want the mouse to be connected, I'd recommend something like x2x, synergy, vnc or an X Windows based screen sharing application.

share|improve this answer
    
Thanks for your answer ! You are right, I maybe need to specify some more things: (1) The workstation is running the GNOME user interface (2) I don't wish to run programs from my laptop. Xeyes or whatever should be run on the workstation with the workstation's monitor (3) That's ok, I understand my cursor will not be connected. –  xApple Sep 27 '11 at 12:27
    
Oh, then you really only need to ssh to the workstation, set the DISPLAY variable to 'localhost:0' (or just ':0') and start your app. You'll still need to deal with permissions (xhost +localhost probably best answer) and either nohup, or &! (background and disown), or bg/disown commands from the shell so app doesn't quit when you log out. (unless that's what you want, of course) –  lornix Sep 27 '11 at 12:34
    
Ah, so maybe my problem is only a permission problem. Although, if I run "xeyes" as root the error message is the same. If you post an answer that solves the permission problems, I can mark it as solved ! –  xApple Sep 28 '11 at 9:17
    
Is anyone logged in to the X windows session on the workstation? Without that, the code that listens for program connections isn't active yet, just the login stuff. (I'm simplifying greatly!) Try ssh'ing to the workstation, then 'startx', THEN you may be able to connect to the display. Another way is to use a bare bones X server, typing 'X :0 &', setting the DISPLAY variable and then performing 'xhost +laptop' (or just 'xhost +'). But that's getting a bit low-level for most. (Great for testing!) –  lornix Sep 28 '11 at 9:58
    
Yes, I logged into a GNOME session on the workstation before disconnecting the keyboard and mouse. None the less I tried executing the "startx" command from my ssh session. The error message was the following: "X: user not authorized to run the X server, aborting." –  xApple Sep 28 '11 at 11:45
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.