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.

I am trying to run Firefox from the terminal on a server using a centos operating system. Whenever I type in the command:

  ssh - X hostname firefox 

I can get firefox to successfully open, but I can not ssh on to the server remotely and open firefox. I get the following error message after specifying export DISPLAY=:0 and typing in "firefox"

No protocol specified
No protocol specified
Error: cannot open display: :0

There are many forums for this problem online and the only useful suggestions I have tried:

export XAUTHORITY=/home/<user>/.Xauthority

Although I need firefox to open under a specific user it will also not open under root.

share|improve this question

migrated from stackoverflow.com Jan 21 '13 at 16:29

This question came from our site for professional and enthusiast programmers.

    
Try it with the -Y switch also. –  Keith Jan 21 '13 at 11:19
    
yep, that also opens a Firefox browser. –  Saz92 Jan 21 '13 at 11:22
    
Oh, SSH doesn't use display 0. Try DISPLAY=:10.0 –  Keith Jan 21 '13 at 11:25
    
thanks for your suggestions, but I'm now getting Error: cannot open display: :10.0. –  Saz92 Jan 21 '13 at 11:29
1  
In that case why do you need it opening on your local machine? The problems you are experiencing are related to opening a GUI program from a remote server and asking it to display on your local machine. If you want to run the tests on the server, none of what you describe sjould be a problem. Perhaps you need to clarify your question? –  terdon Jan 21 '13 at 17:43

2 Answers 2

Normally, on a trusted network (i.e. home network, etc.) you could get away with

xhost +hostname

This enables X11 host control for your local display. It allows a X11 connection from the remote host hostname to connect to your local X11 server.

Please keep in mind that X11 host control is an old, old mechanism that is not inherently secure. It provides a rudimentary means of access control through IP addresses or host name resolution. This is why you would use ssh to connect to a remote host: it encrypts all of the data and secures the connection point to point.

In this case, it will not be needed, as your remote environment should be (sanely) set up to allow IP access through the loopback device. But it is listed here for reference.

ssh -x remotehostname "DISPLAY=localhost:10.0 firefox"

When ssh connects, and you specify X11 forwarding through the -x switch, a binding will be made on the loopback connector (address 127.0.0.1) for display number 10 (this is typically the default, although it can be changed). The DISPLAY environment variable is typically used to divert the connection of an X11 program to some other display or machine.

So, we are effectively setting the environment variable that tells firefox to connect to a fake display 10.0 residing on 127.0.0.1, which ssh will then tunnel backwards to your local X11 display.

share|improve this answer
    
What does it do? How do I know it won't damage my system? This answer needs some explanation. –  gronostaj Aug 25 at 21:06
    
Answer is briefly amended. I don't have enough time to really spell everything out at the moment, as I have more pressing things to tend to. –  Avery Payne Aug 25 at 23:17

Try lowercase x !? Also make sure you don't have a space between the '-' and 'x'

ssh -x hostname firefox

An alternative to try out (more wordy method but might give you a different error message that is more helpfull):

originalhost > ssh remotehost remotehost > setenv DISPLAY originalhost:0

originalhost > xhost + remotehost > firefox

share|improve this answer

Your Answer

 
discard

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