Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have Firefox running, and from the command line I can open a new tab by just typing:


What I'm trying to accomplish is similar, but remotely. I have Firefox running on machine B. From machine A I want to be able to run (after setting whatever ssh tunneling or similar is needed) something like:


However the tab should open not on machine A, but rather on machine B. I don't want X11 forwarding, I just want to be able to instruct Firefox on a remote machine to open a given URL.

Any ideas?

share|improve this question

migrated from Jul 18 '11 at 12:07

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

On the machine where Firefox will run and display (machine A), you need to:

  • Specify which X server to connect to, e.g. set DISPLAY=:0.0 .
  • Authenticate somehow to the X server. An easy way is to read the value of $XAUTHORITY in the X session and use the same one.

For example, in a terminal in the X session do:


Then from the SSH terminal, do, as the same user as the X session (otherwise use su):

DISPLAY=:0.0 XAUTHORITY=/var/run/gdm/auth-for-ambro-j3bu8Q/database firefox

You can have the value of $XAUTHORITY automatically written somewhere when you login. For example, create the following script ~/write-xauth (don't forget to chmod +x):

touch "$HOME"/.saved-xauthority
chmod u=rw,g=,o= "$HOME"/.saved-xauthority
echo "$XAUTHORITY" > "$HOME"/.saved-xauthority

Then create an autostart file that will run the above script, ~/.config/autostart/save-xauthority.desktop :

[Desktop Entry]
Name=Save XAUTHORITY to .saved-xauthority

Once you have a shell on machine B (the machine on which firefox will not display), you just have to SSH to machine A (where firefox will run and will display) and run the firefox command I posted. It is possible to automate this into a script on machine B. You'll have use keys (rather than password) for SSH authentication to machine A. For example, see . This will allow you to ssh non-interactively without entering a password. Now you can run commands on machine A from machine B by typing:

ssh machineA command argument ...

In your case, you'd probably want to make a script on machineA for opening the Firefox window:

ssh machineA ./open_local_firefox http://whatever

And this script would look something like:

export DISPLAY=:0.0
export XAUTHORITY=$(cat "$HOME"/.saved-xauthority)
firefox "$1" &>/dev/null 2>&1 &

It's worth noting that this setup will allow machine B to run anything on machine A as the user you're SSHing as. It's possible to limit this, but it's not easy. If you want to do this with SSH, sshd's ForceCommand option would probably help.

There are other ways of doing this of course, but it all boils down to running the 'firefox' command on machine A with the right environment vars (as shown above) as the right user. For example, you can set up an HTTP server and a script on machine A, such that a certain POST request will open that Firefox window. This is probably easier to secure than the SSH approach.

share|improve this answer
Hi,thanks for the reply, but as I said in my question, I'm not looking for X11 forwarding, which in my use case would be too slow. I'm trying to find a way to instruct a firefox running in a remote computer to open a given URL. – Angel de Vicente Jul 18 '11 at 23:16
This is not X11 forwarding; it is about starting Firefox remotely (via an SSH session) to display itself on the remote system (not the one where the client is running). – Ambroz Bizjak Jul 19 '11 at 0:20
Ah, OK, I misunderstood it, but I'm not sure this will work, anyway. Let me clarify: I'm at machine A, where I am running Firefox. I connect via ssh to machine B. From machine B I want to tell (via a scirpt) the Firefox in machine A to open another tab with another URL. I'll try again, and I will report back. – Angel de Vicente Jul 19 '11 at 8:21
It will work, you just have to SSH back to machine A and start firefox the way I told you to. I've added more info now that you've explained your problem more completely. – Ambroz Bizjak Jul 19 '11 at 9:05
OK, thanks. I will try (hopefully today) it. Firefox has been quite stubborn in the past when I was trying to run it remotely... – Angel de Vicente Jul 19 '11 at 9:30

Your Answer


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.