SSH from Windows to Linux VM. Cannot invoke firefox: no display specified

08
2014-07
  • user334430

    I have been at this for the past two days and still no luck.

    $ firefox
    Error: no display specified
    
    $ firefox &
    [1] 25977
    Error:no display specified
    ^C ^C
    [1]+ Exit 1
    

    I am on a Windows7 machine and I'm trying to get Firefox to open on the CentOS machine, but be displayed on my current screen (Windows 7). When typing firefox in terminal, I am getting the following error:

    Error: cannot open display: localhost:0.0
    

    To setup the display I used the command

    $ export DISPLAY=localhost:0.0
    

    Some site suggested using the following, but it didn't work either:

    $ export DISPLAY=:0.0
    

    Do I really need Xming?

    Does anyone know of reliable resources so I can get a better knowledge concerning running applications (e.g. router traffic graphers, Apache, a simple index.html page) off of a virtual machine to be viewed on my desktop via PuTTY?

    I really do not want to download Xming or an X server. Is this necessary?

    I understand when I am run the command firefox or firefox & the server looks for a GUI however it is not "pointed" at my desktop.

    I have used the command export.

  • Answers
  • Daniel Serodio

    Plain SSH will allow you to work with CLI tools like Apache, etc.

    For GUI tools, like Firefox, you'll need an X server like xming. SSH will transmit the X "commands" (graphics command like "draw a window", etc.) between Linux and Windows, but you need a X server to actually draw the Firefox window on your Windows machine.

  • nochkin

    If the CentOS machine is remote, you have to specify your IP address where you have X server (i.e. XMing) running when doing "export DISPLAY". Also, you must have the X11 port opened as well.

    Your firewall rules may be blocking it, so the best alternative is to use "ssh x11 forwarding" in your ssh client. That will set DISPLAY environment variable upon connection automatically, so the only thing you have to do on your Windows 7 machine is to install the X server (XMing).

    For example, if you use Putty, the ssh x11 forwarding can be enabled in Connection - SSH - X11 - X11 forwarding.


  • Related Question

    Call putty/plink to start a remote SSH linux script with user input
  • IanVaughan

    Seemingly simple question, which yields slightly undesired results.

    Execute putty to start a script on a remote linux server which requires user input

    The remote script does a read -p "Please enter name" NAME
    I can use plink to execute a script over SSH, the following attempts and problems are shown below :- Note the -load ns is to load a session that doesnt exist, ie ensure no defaults are used

    1) plink.exe -load ns <ip_addr> -l <user> -pw <password> <script path/name> Problem) Doesn't allow/show user input, ie its non-interactive.

    2) Add -t to allocate a pty :-
    plink.exe -t -load nc <ip_addr> -l <user> -pw <password> <script path/name> Problem) Ok, so now the user input can be seen, but I get Ctrl+H (^H) when backspace is pressed, ok if the user doesnt make a mistake!

    3) Use putty instead with a saved session
    putty.exe -load "SavedSession"
    Problem) (a) Get a new window opened, not a biggy, but not as nice. (b) saved session cannot be easily moved. (c) Get password prompt, cannot provide password like with plink, I know I know, use keys, but this is a closed, private network, and its easier not to bother with keys!

    So ideally, I would like the SSH to execute in-line, that is from within the batch file/command line shell I am in, not prompt for username/password, run the linux script and allow prompts and delete/backspace to work.

    Many thanks for any ideas/solutions in advance.


  • Related Answers
  • grawity

    Add -t to allocate a pty ... Ok, so now the user input can be seen, but I get Ctrl+H (^H) when backspace is pressed

    Make your script run [ -t 0 ] && stty erase ^H and the Backspace key should be accepted.

    An even better solution is to use a port of OpenSSH – for example, that from Cygwin or MinGW – it will give you full terminal emulation as PuTTY does, but keep it in the console window. (The plink tool is designed for raw 8-bit data transfers.)

    Edit: A downside of Cygwin might be its lack of IPv6 support (if I remember correctly).


    Get password prompt, cannot provide password like with plink

    [...] but this is a closed, private network, and its easier not to bother with keys!

    And yet you have a problem which setting up keys would solve :)

    (I'll feel bad for saying this, but PuTTY also accepts -pw.)