I want to run selenium tests on a Hudson slave.
The slave (i.e. the machine) that will execute the selenium is a Ubuntu 10.04.
Thus it has Gnome. Selenium needs a firefox to run.

What Hudson does now is, it creates a ssh connection to the Ubuntu machine and launches selenium there. Selenium tries to start a firefox.

And now it blames:

Error: cannot open display

What needs to be done that the 'ssh shell' gets a display from the X-server?

  • I think many people are misunderstanding your question, or I am. To be clear, do you intend for Firefox to run on the Ubuntu machine and display on the Ubuntu machine? I.e. you are not asking how to have Firefox display back to the Hudson server, (which only triggers the test) – Norky Jun 10 '11 at 8:19
  • have you seen this rather similar question: serverfault.com/questions/108781/… ? – Norky Jun 10 '11 at 10:36

Make sure that the remote machine has ssh X11 forwarding enabled:

$ grep X11 /etc/ssh/sshd_config 
X11Forwarding yes
X11DisplayOffset 10

Use ssh -X user@remote_machine to connect to remote machine. If on remote machine you are using a different user to start the X client, use xauth list to get the current credentials in the ssh user, then use xauth add to add the credentials to the user you are becoming with sudo/su.

read -p 'Username: ' u;sudo -H -u $u xauth add $(xauth list|grep :$(echo ${DISPLAY: -4:2}));sudo su - $u
  • If one has a firefox running on the local machine the '-no-remote' command line switch should be used to really run a new instance. (firefox would discover the already running one and quit silently) – cstamas Jun 10 '11 at 7:55
  • Thanx. The given command works. But the problem is, that I need to get Hudson to append the X paramter to the ssh command. But I guess this is not the right forum for hudson specific settings. – nebenmir Jun 10 '11 at 9:18

If the question is what I think it is

ssh testuser@ubuntuhost firefox --display :0 -no-remote

Will start firefox on ubuntuhost and have it display on that machine, assuming testuser is logged on to ubuntuhost already.

I don't know Selenium, or what exactly you're looking to test (performance, correctness of display, or simply a success return value from some javascript) but you might not even need a 'real' X server, i.e. one that actually appears on the monitor of the Ubuntu host. Xvfb might be helpful for you here, but that's beyond the scope of the original question...

  • I'm sorry but that does not work. Still get foo@hitchhiker:~$ ssh ci@kabul firefox -display :0 -no-remote ci@kabul's password: Error: no display specified – nebenmir Jun 10 '11 at 9:10
  • @nebenmir: sorry, my mistake, firefox takes "--display", not "-display" – Norky Jun 10 '11 at 11:01
  • thanks a lot, very usefull with firefox imacros plugin as well !! – S12000 Dec 26 '15 at 20:07

You need to enable X forwarding, and run an X server locally. Pass -X or -Y to ssh.


ssh -X root@myserver or something like that


You need to forward X over the ssh tunnel, try this:

ssh -X host_IP

once logged in, start firefox in your terminal, it should forward your X-server to your local machine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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