我家里的笔记本电脑上安装了 SSH,它运行良好。我设置了隧道:
$ ssh -p 443 -C2TNv -D 8080 [email protected]
Firefox 设置:
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
,会发生以下情况:
- 您的应用程序(在本例中为浏览器)连接到您指定的本地 socks 端口。
- 本地运行的ssh程序作为SOCKS服务器,从浏览器获取请求的主机和端口。
- 本地请求在您指定的主机上运行的
ssh
远程(在您的情况下)打开到请求的主机和端口的连接。sshd
me.no-ip.org
- 本地
ssh
和远程sshd
之间建立一个隧道,用于在浏览器建立的本地连接和 建立的远程连接之间转发流量sshd
。这就是隧道。