JD *_*win 5 ssh firefox tunnel kubuntu socks5
我无法通过隧道 SOCKS 代理使用 Firefox 连接到网站。SOCKS4/SOCKS5 没有区别。
我建立了隧道
ssh -D 1234 id@remotehost.example.com
然后将 Firefox 的 SOCKS 代理指向 tcp/1234 上的 localhost。
这里需要注意的一个关键点是,我正在设置的隧道位于我多年来一直为此目的使用的远程服务器上。我已经通过它代理了 FF 和其他浏览器在所有主要操作系统的十几个或更多不同平台上的数千个会话。一旦我开始工作,它总是能顺利运行。然而,在这个特定的 FF 实例上,我遇到了奇怪和间歇性的问题。
问题是 FF 似乎并不“想要”建立连接。我输入一个 URL 或单击一个链接,我立即得到“无法连接”/“Firefox 无法建立与服务器的连接......”当我说“立即”时,我的意思是这会弹出来几分之一秒。
所以我点击“再试一次”或小重新加载箭头。我一次又一次地这样做,尽可能快。经过几次尝试——有时是 3-4 次,有时多达 15-20 次——我建立了连接,一切正常!所以隧道/SOCKS连接是可用的,只是FF拒绝使用它,直到它被欺负这样做。一旦我建立了连接,进一步的重新加载不会导致它丢失。
我有一些附加组件,但是 a) 我在没有帮助的情况下有选择地禁用了它们,并且 b) 我(当然)尝试了安全模式。没有变化。
有什么建议?
我必须每天在工作中使用代理才能连接到防火墙另一侧的服务器。我还使用 Firefox、Chrome 和 Ubuntu 16.04。
编辑: 我忘记了其中的一部分。我不得不向 ssh 配置文件添加超时,否则我的隧道将超时并且我失去连接。添加以下内容后,我的连接将保持打开状态:
在~/.ssh/config添加以下信息(如果该文件不存在,创建它。)。这将每 15 秒向您的隧道发送一个服务器 keepalive。
Host *
ServerAliveInterval 15
Run Code Online (Sandbox Code Playgroud)
我使用以下命令打开隧道连接:
ssh -CfND 1234 username@proxyhost
Run Code Online (Sandbox Code Playgroud)
然后在 Firefox的手动代理配置中的连接设置下,我只填写SOCKS 主机: 127.0.0.1 和端口: 1234。然后我确保选择了SOCKS v5。 另请注意,我在 No Proxy for: 框中没有任何内容。
我能够以这种方式连接到我的主机,没有任何问题。
然后对于 Chrome,我运行了一个命令行,这样我就不必每次想通过代理时都将设置设置为 Chrome,然后没有代理。要将 Chrome 连接到代理,我运行以下行:
nohup google-chrome-stable --proxy-server="socks5://127.0.0.1:1234" & > /dev/null 2>&1
Run Code Online (Sandbox Code Playgroud)
from ssh manpage
-C Requests compression of all data (including stdin, stdout,
stderr, and data for forwarded X11, TCP and UNIX-domain connec?
tions). The compression algorithm is the same used by gzip(1),
and the “level” can be controlled by the CompressionLevel option
for protocol version 1. Compression is desirable on modem lines
and other slow connections, but will only slow down things on
fast networks. The default value can be set on a host-by-host
basis in the configuration files; see the Compression option.
-f Requests ssh to go to background just before command execution.
This is useful if ssh is going to ask for passwords or
passphrases, but the user wants it in the background. This
implies -n. The recommended way to start X11 programs at a
remote site is with something like ssh -f host xterm.
-N Do not execute a remote command. This is useful for just for?
warding ports.
-D [bind_address:]port
Specifies a local “dynamic” application-level port forwarding.
This works by allocating a socket to listen to port on the local
side, optionally bound to the specified bind_address. Whenever a
connection is made to this port, the connection is forwarded over
the secure channel, and the application protocol is then used to
determine where to connect to from the remote machine. Currently
the SOCKS4 and SOCKS5 protocols are supported, and ssh will act
as a SOCKS server. Only root can forward privileged ports.
Dynamic port forwardings can also be specified in the configura?
tion file.
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助!
不幸的是,这个问题是间歇性的,这使我的故障排除工作变得混乱。@Terrance 上面给出的答案(我将其标记为“答案”)实际上并不能解决我的问题。这似乎有效,而且确实有效了一段时间。然后我又遇到了问题。有时停止我的 ssh 会话并重新启动它可以暂时解决问题,有时重新启动也没有什么区别。
该建议在其他地方提到了这个线程——即在浏览器的代理设置中指定 127.0.0.1 而不是“localhost” ——同样似乎有所不同,但最终无效。我之前回答说这是浏览器连接工作和不工作之间的关键区别,但同样这还为时过早。我的浏览器通过隧道与网站建立连接的能力仍然间歇性地出现问题。
我现在已经获得了关于这个问题和下面提到的解决方案的足够额外经验,因此我对OpenSSH 本身存在某种短超时错误的结论很有信心。顺便说一句,我的版本是
OpenSSH_7.2p2 Ubuntu-4ubuntu1、OpenSSL 1.0.2g-fips 2016 年 3 月 1 日
我这样做的依据是:a) 该问题显然与浏览器无关(已在 Firefox、Chromium 和 w3m 中验证);b) 使用备用 ssh 客户端已可靠地解决了该问题。
我下载了源代码并构建并安装了 PuTTY(从此链接)。注意:确保安装虚拟包 gtkgl-dev,以便 PuTTY 源可以找到头文件。然后我像过去多次在 Windows 中一样进行设置,现在它已经正常工作了大约两天。零失败。
我确信这已得到修复,并且当前 OpenSSH 中存在错误。我将努力就此做出报告。
出于这个问题的目的,我选择我自己的答案作为答案,尽管上面@Terrence的答案仍然非常有用。
| 归档时间: |
|
| 查看次数: |
10501 次 |
| 最近记录: |