如何在 Firefox 中透過 SOCKS 透過 SSH 建立 HTTP 隧道

如何在 Firefox 中透過 SOCKS 透過 SSH 建立 HTTP 隧道

我的家用筆記型電腦上安裝了 SSH,並且運作良好。我設定了隧道:

$ ssh -p 443 -C2TNv -D 8080 [email protected]

火狐瀏覽器設定:

manual config:
SOCKS; port 8080
V5

about:config:

network.proxy.socks_remote_dns: true

終端輸出:

OpenSSH_5.9p1, OpenSSL 0.9.8t 18 Jan 2012
debug1: Reading configuration data /etc/ssh_config
debug1: Connecting to me.no-ip.org [] port 443.
debug1: Connection established.
debug1: identity file /home/me/.ssh/id_rsa type -1
debug1: identity file /home/me/.ssh/id_rsa-cert type -1
debug1: identity file /home/me/.ssh/id_dsa type -1
debug1: identity file /home/me/.ssh/id_dsa-cert type -1
debug1: identity file /home/me/.ssh/id_ecdsa type -1
debug1: identity file /home/me/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9
debug1: match: OpenSSH_5.9 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 [email protected]
debug1: kex: client->server aes128-ctr hmac-md5 [email protected]
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: <removed>
debug1: Host '[me.no-ip.org]:443' is known and matches the host key.
debug1: Found key in /home/me/.ssh/known_hosts:2
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Trying private key: /home/me/.ssh/id_rsa
debug1: Trying private key: /home/me/.ssh/id_dsa
debug1: Trying private key: /home/me/.ssh/id_ecdsa
debug1: Next authentication method: keyboard-interactive
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: password
[email protected]'s password:
debug1: Enabling compression at level 6.
debug1: Authentication succeeded (password).
Authenticated to me.no-ip.org ([removed]:443).
debug1: Local connections to LOCALHOST:8080 forwarded to remote address socks:0
debug1: Local forwarding listening on ::1 port 8080.
debug1: channel 0: new [port listener]
debug1: Local forwarding listening on 127.0.0.1 port 8080.
debug1: channel 1: new [port listener]
debug1: Requesting [email protected]
debug1: Entering interactive session.

然後訪問任何網站都會顯示:“代理伺服器不接受連接”

請指教。

答案1

我必須從 Putty 中更改隧道設定。我必須檢查動態和 IPv4 的氣泡;現在工作正常。

答案2

您需要在遠端執行sshd,並且需要透過 ssh 連線到它,而不是 Web 伺服器。

$ ssh -C2TNv -D8080 [email protected]

要連接的實際主機和連接埠由瀏覽器指定為每個 SOCKS 請求的一部分。

當您使用 建立 SOCKS 隧道時ssh -D,會發生以下情況:

  • 您的應用程式(在本例中為瀏覽器)連接到您指定的本機襪子連接埠。
  • 本機運行的ssh程式可作為SOCKS伺服器,從瀏覽器取得請求的主機和連接埠。
  • 本機請求在您指定的主機上執行的ssh遠端(在您的情況下)開啟與所要求的主機和連接埠的連線。sshdme.no-ip.org
  • 本地ssh和遠端sshd在它們之間建立一條隧道,以在瀏覽器建立的本地連接和sshd.這是隧道。

相關內容