如何通过SSH启动远程firefox窗口?

当我SSH到远程盒子时

$ ssh -X remotebox 

然后在远程盒子上启动firefox

 remotebox$ firefox 

我在我的本地机器上运行firefox,将打开一个本地firefox窗口。 远程盒子上没有运行firefox进程。

如果firefox没有在我的本地计算机上运行,​​那么将打开一个远程firefox窗口。

为什么要打开一个本地firefox窗口? 我怎么能防止这种情况?


这里有一些我本地系统的更多信息。

 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 

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 

以下命令启动带有远程firefox窗口的远程firefox会话。

 remotebox$ firefox -no-remote 

以下命令产生一个短暂的延迟,然后回退到提示符并弹出一个本地firefox窗口。 没有firefox进程在remotebox上运行。

 remotebox$ firefox 

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 

remotebox2上的以下命令按预期启动远程firefox会话。

 remotebox2$ firefox 

我不知道为什么firebox2上的firefox启动远程会话而不是本地会话。

除了firefox -no-remote之外,另一个参数是firefox -no-xshm ,它揭示了用于使其工作的技术。

X11共享内存是一种进程间通信技术,可供连接到给定x服务器会话的所有应用程序使用。 它可用于执行拖放和其他类型的桌面交互。

它也可以(并且)用于实现“一次打开”应用程序,以减少占用空间(或窗口数量)。

由于X11协议是网络透明的,因此“共享内存”也扩展到远程X11客户端。

尝试firefox -no-remote

注意,我做了圆顶挖掘,因为这让我烦恼,你也可以添加:

 MOZ_NO_REMOTE=1 export MOZ_NO_REMOTE 

到你的个人资料

你可以尝试这个,当你连接到机器( ssh user@host ;注意:没有-X选项)时,首先输入follow命令

 export DISPLAY=:0 

这会将默认显示更改为当前桌面屏幕的显示。 然后输入

 firefox 

在桌面窗口中生成firefox。 确保您已登录桌面,如果没有登录桌面(无登录),您将收到以下错误;

 firefox: cannot connect to X server :0 

此方法也适用于锁定的桌面。 请确保您已使用相同的用户名登录桌面和ssh shell。

当存在多个桌面会话时,每个会话由不同的编号标识为:0:1:2等。

没有其他解决方案对我有用,所以这是在对其他网站进行一些搜索之后。

您需要在单独的进程中运行firefox,就像在本地计算机上执行它一样。 使用概要文件管理器创建新的概要文件,如下所示。

 export MOZ_NO_REMOTE=1 firefox -ProfileManager 

为了保持一致,我决定将外部机器上的每个新配置文件命名为与主机名相同。

简单的远程浏览

如果您想在本地浏览网页,就像坐在远程盒子前面一样:

 $ ssh -X username@remote.example.com 

然后在远程终端会话中运行Firefox:

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

注意ssh命令中-X标志的用法。 您也可以一次完成这两个步骤,如下所示:

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

隧道远程IP:端口

如果您有一个远程运行的应用程序,它暴露了某种Web前端,您将有兴趣公开远程IP:端口,就像它是本地IP:端口一样。 在这种情况下, -L选项定义localhost:localportremotehost:remoteport之间的对应关系,如下面的伪命令所示:

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

例如:

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

然后在本地运行Firefox:

 $ firefox http://127.0.0.1:18080 

在上面的示例中,您通过SSH连接到username@router.example.com ,并且您对在internal.example.com:8080上公开的Web前端感兴趣。 此远程IP:端口将在127.0.0.1:18080本地公开。

我只想补充一下对我有用的东西。 简单地使用firefox -no-remote失败了常见的错误

 Error: GDK_BACKEND does not match available displays 

但是,以下工作:

 ssh -Y user@host firefox -no-remote 

-Y选项启用可信X11转发。 受信任的X11转发不受X11 SECURITY扩展控制的约束。 您可以考虑在ssh命令中添加-C选项以启用压缩。