Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have logged in to a remote server and am trying to display an x application(e.g. firefox). but an error message appears. the below are my attempts to open firefox

Black@Black-PC ~
$ ssh -X kwagjj@$labserver -p 122
[kwagjj@James5 ~]$ firefox
Error: no display specified
[kwagjj@James5 ~]$ exit
logout
Connection to 143.248.146.204 closed.

Black@Black-PC ~
$ ssh -Y kwagjj@$labserver -p 122
[kwagjj@James5 ~]$ firefox
Error: no display specified
[kwagjj@James5 ~]$ 

I used -X, -Y because I read somewhere that these two options are related with credentials regarding X11 and these switches will do the job for me. Even without the -X, -Y switches, my attempt failed.

What does the 'no display speicified' error mean?

P.S. The weird thing is that if I connect to the remote server through my PUTTY and repeat the command 'firefox' it works?!?!(firefox is displayed on local computer)

P.S. my local computer is Windows 7 so I have Xming running on background in order to allow X11 display. As for the attempt written on the upper part, the commands were typed in at Cygwin terminal.

share|improve this question
    
Have you tried to display something locally from your Cygwin terminal? For example, you could find a local X utility such as xclock and run it to see what happens. If you cannot display locally, the remote display won't work. You may also need the X server for Cygwin. –  unxnut Jun 24 at 12:51
    
@unxnut as you've pointed out, my DISPLAY variable wasn't set. so I set it up with export DISPLAY=:0.0' and executed xclock` and the xclock appeared. But when I then logged in to the remote server via ssh, and tried xclock again, it says Error: Can't open display: –  kwagjj Jun 24 at 12:59

2 Answers 2

up vote 3 down vote accepted

Make sure that you have the DISPLAY-variable set in your cygwin-environment:

export DISPLAY=:0.0

after connecting with SSH, check if that shell also knows the correct DISPLAY-variable with:

echo $DISPLAY
share|improve this answer
    
I set up the DISPLAY variable in the cygwin termnial of local computer and afterwards ssh'ed to remote server and typed echo $DISPLAY . But still the DISPLAY variable in the remote server is set to nothing.. –  kwagjj Jun 24 at 13:01

Thanks to @jensd, @unxnut for helping me. based on your comments I was able to figure out the problem.

The solution needed two steps:

  1. the DISPLAY variable should be properly set.
  2. when ssh'ing to remote server, the -X switch must be on

my previous attempts lack one or both of these two conditions.

Anyhow, for later users who see this here's are examples to show you what I'm trying to say.

case1

my local machine will have no DISPLAY variable set. And then I will ssh to remote server with -X switch and then try executing xclock.

Black@Black-PC ~
$ echo $DISPLAY

## the blank means that DISPLAY variable has not been specified##
Black@Black-PC ~
$ ssh -X kwagjj@$labserver -p 122
Last login: Tue Jun 24 22:23:13 2014 from 
[kwagjj@James5 ~]$ xclock
Error: Can't open display:
[kwagjj@James5 ~]$ setenv | grep $DISPLAY
DISPLAY: Undefined variable.

as you can see an error Error: Can't open display: is shown at the remote server terminal.

case2

this time, at the local machine, I will specify the DISPLAY variable. But when I'm ssh'ing, I won't turn on the -X switch. The result will be a failure:

Black@Black-PC ~
$ export DISPLAY=:0.0

Black@Black-PC ~
$ echo $DISPLAY
:0.0

Black@Black-PC ~
$ ssh kwagjj@$labserver -p 122
Last login: Tue Jun 24 22:33:32 2014 from 
[kwagjj@James5 ~]$ xclock
Error: Can't open display:
[kwagjj@James5 ~]$ setenv | grep DISPLAY
[kwagjj@James5 ~]$ 

at the start you can see that I have properly set the DISPLAY variable. But even so, after ssh'ing(without the -X switch) the xclock is not executed.

*A different outcome with setenv | grep DISPLAY can be seen here(compare with case1). in case2, the result is just blank. on the other hand, the result of case1 to this command line is DISPLAY: undefined variable.... I'm not sure how this difference is caused but I'm getting a hunch that its related to whether you've satisfied either condition 1. or 2.

case3

this time, I will properly specify the DISPLAY variable at the local machine and also ssh to remote server with my -X switch on.

Black@Black-PC ~
$ echo $DISPLAY
:0.0

Black@Black-PC ~
$ ssh -X kwagjj@$labserver -p 122
Warning: untrusted X11 forwarding setup failed: xauth key data not generated
Warning: No xauth data; using fake authentication data for X11 forwarding.
Last login: Tue Jun 24 22:37:27 2014 from 
[kwagjj@James5 ~]$ xclock &
[1] 9174
[kwagjj@James5 ~]$ setenv | grep DISPLAY
DISPLAY=localhost:11.0
[kwagjj@James5 ~]$

with this setting, xclock works!! here's a screenshot to prove that I'm not lying. enter image description here the xclock is successfully shown in my local machine.

Again, check out the result of setenv | grep DISPLAY in this case. It now shows DISPLAY=localhost:11.0. From what I know, this is related with MIT-MAGIC-COOKIE in the .Xauthority file but since I don't know much about this I won't go any further.

Conclusion: from the three cases above, we can confirm that in order for remote X Windows to be displayed properly, both 1. DISPLAY variable of local machine and 2. ssh -X switch must be properly set. Of course, the remote server should allow X11forwarding.

share|improve this answer

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.