55

When I SSH to a remote box

$ ssh -X remotebox

then start firefox on the remote box

remotebox$ firefox

and I have firefox running on my local machine, a local firefox window will open. no firefox process is running on the remote box.

If firefox is not running on my local machine then a remote firefox window will open.

Why is it opening a local firefox window? How can i prevent that?


Here some more information of my local system.

Linux lesmana-laptop 2.6.32-24-generic #42-Ubuntu SMP Fri Aug 20 14:24:04 UTC 2010 i686 GNU/Linux

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 10.04.1 LTS
Release:    10.04
Codename:   lucid

DISPLAY=:0.0

Mozilla Firefox 3.6.8, Copyright (c) 1998 - 2010 mozilla.org

Information of remotebox.

Linux dxray 2.6.22.19-0.4-default #1 SMP 2009-08-14 02:09:16 +0200 x86_64 x86_64 x86_64 GNU/Linux

LSB Version:    core-2.0-noarch:core-3.0-noarch:core-2.0-x86_64:core-3.0-x86_64:desktop-3.1-amd64:desktop-3.1-noarch:graphics-2.0-amd64:graphics-2.0-noarch:graphics-3.1-amd64:graphics-3.1-noarch
Distributor ID: SUSE LINUX
Description:    openSUSE 10.3 (X86-64)
Release:    10.3
Codename:   n/a

DISPLAY=localhost:15.0

Mozilla Firefox 3.0.14, Copyright (c) 1998 - 2009 mozilla.org

The following command starts a remote firefox session with a remote firefox window.

remotebox$ firefox -no-remote

The following command produces a brief delay, then drops back to prompt and a local firefox window pops up. No firefox process running on the remotebox.

remotebox$ firefox

Information of remotebox2.

Linux marvin 2.6.31-22-generic #60-Ubuntu SMP Thu May 27 00:22:23 UTC 2010 i686 GNU/Linux

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 9.10
Release:    9.10
Codename:   karmic

DISPLAY=localhost:11.0

Mozilla Firefox 3.6.8, Copyright (c) 1998 - 2010 mozilla.org

The following command on remotebox2 starts a remote firefox session as expected.

remotebox2$ firefox

I do not know why firefox on remotebox2 starts a remote session instead of a local session.

  • Can we get the contents of the $DISPLAY variable on both the local and the remote machine? – aperson Sep 3 '10 at 8:13
  • @aperson, updated question. – lesmana Sep 3 '10 at 10:33
  • Thanks, the $DISPLAY doesn't seem to be an issue, ssh appears to be setting things up properly. – aperson Sep 3 '10 at 18:46
46

besides firefox -no-remote another parameter is firefox -no-xshm which reveals the technique used to make it work.

X11 shared memory is an interprocess communication technique which can be used by all applications connected to a given x server session. It can be used to perform drag & drop, and other kind of desktop interaction.

It can be (and is) used also to implement "open once" applications, in order to reduce the footprint (or the number of windows).

Since the X11 protocol is network transparent the "shared memory" is extended also to remote X11 clients.

  • Is there any way I can make x not do this? I am looking to containerize a video game/wine setup for easy distribution, but this is causing me headaches, because it will cause unspecified behaviour depending on what the user of the container has installed and running. I am using this solution to do the x forwarding: stackoverflow.com/a/25168483 and would like to simply make sure the container never shares memory with the host. – Sir Substance Jan 6 '15 at 0:35
  • It doesn't work for me – Bob Ebert Mar 10 '16 at 3:40
  • Try the lower suggestion: export MOZ_NO_REMOTE=1 – Kieveli Jan 26 '17 at 20:37
14

Try firefox -no-remote

  • this works in opening a remote firefox window. but i still do not understand why a remote command can trigger a local firefox window to open. – lesmana Sep 3 '10 at 6:53
  • @lesmana this may be due to x11-forwarding - if that is setup in the sshd_config you may have a situation where it's being executed and tunneled back through. – Marco Ceppi Sep 4 '10 at 0:08
10

Note, I did dome digging as this was bugging me and you can also just add:

MOZ_NO_REMOTE=1
export MOZ_NO_REMOTE

to your profile.

4

You can try this, when you connected to machine (ssh user@host; note: without -X option), first type the follow command

export DISPLAY=:0 

this would change the default display to that of the current desktop screen. And then just type

firefox

to have firefox spawned on the desktop window. Ensure that you have logged into the desktop, without which (no logins) you will get the following error;

firefox: cannot connect to X server :0

This method would work for locked desktops as well. Please ensure that you have logged in on the desktop and the ssh shell with the same username.

When there are multiple desktop sessions, each session is identified by a different number as :0, :1, :2, etc.

  • That's the only answer that worked for me. – answerSeeker Jul 10 '17 at 3:18
2

None of the other solutions worked for me, so this was after a little bit of searching on other sites.

You need to run firefox in a separate process the same way you would if you were doing it all on the local machine. Use the profile manager to create a new profile as follows.

export MOZ_NO_REMOTE=1
firefox -ProfileManager

To keep things consistent, I decided to name each new profile on the external machine the same as the hostname.

1

Simple remote browsing

If you'd like to browse the web locally as if you were sitting in front of a remote box:

$ ssh -X username@remote.example.com

then run Firefox inside the remote terminal session:

$ firefox https://test-ipv6.com/

Notice the usage of -X flag in the ssh command. You can also do both steps in a single go, like shown below:

$ ssh -X username@remote.example.com firefox http://test-ipv6.com/

Tunnelling a remote IP:port

If you have an application running remotely which exposes some sort of web frontend, you will be interested on exposing the remote IP:port as if it is a local IP:port. In this case, the -L option defines a correspondence between localhost:localport and remotehost:remoteport, as shown in the pseudo command below:

ssh -L localhost:localport:remotehost:remoteport remoteuser@remotehost

For example:

$ ssh -L 127.0.0.1:18080:internal.example.com:8080 username@router.example.com

then run Firefox locally:

$ firefox http://127.0.0.1:18080

In the example above, you are connecting via SSH onto username@router.example.com, and you are interested on a web frontend exposed at internal.example.com:8080. This remote IP:port will be exposed locally at 127.0.0.1:18080.

0

I'll just add what worked for me. Simply using firefox -no-remote failed with the usual error

Error: GDK_BACKEND does not match available displays

However, the following worked:

ssh -Y user@host
firefox -no-remote

The -Y option enables trusted X11 forwarding. Trusted X11 forwardings are not subjected to the X11 SECURITY extension controls. You could consider adding -C option to ssh command for enabling compression as well.

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.