假设我在典型的家用路由器中有一台计算机(但说防火墙/端口转发访问路由器不可用)。它的内部 IP 可以是 192.168.1.81。LAN 上有一台 IP 为 192.168.1.85 的攻击者机器想要对 192.168.1.81 进行典型的 ARP 欺骗中间人攻击(假设他想运行类似 urlsnarf 的东西来嗅探访问过的网站)。192.168.1.81 机器想要防止任何形式的 MITM 攻击并在 Chrome 上浏览互联网时保持安全。他有一个具有 SSH 访问权限的服务器,他想用它来加密他的 Web 浏览,这样攻击者就无法通过 MITM 攻击来嗅探它。我(希望使用 SSH 隧道以保持安全的用户)如何在我的服务器(在公共 IP 162.xx.xxx.xx)上使用 SSH 隧道来防止潜在的 MITM 攻击?这是一个科学博览会项目。我必须在我的服务器上进行哪些(如果有)设置(我有完全的 root 访问权限)?我的SSH端口与常态不同,请以SSH端口25512为参考。我也在防火墙上为服务器打开了4567端口,请参考这个端口。请使用 72.xxx.xx.xxx 作为家庭网络的公共 IP。请包括任何必要的命令。让我知道是否需要更清楚。非常感谢任何可以提供帮助的人!让我知道是否需要更清楚。非常感谢任何可以提供帮助的人!让我知道是否需要更清楚。非常感谢任何可以提供帮助的人!
最简单的方法是在远程服务器上运行代理(fe squid)并使其仅在本地接口上侦听127.0.0.1
(因为您不想打开 Internet 代理)。
然后通过 ssh 进入远程服务器并创建一个 tcp 转发到远程服务器上的本地代理接口。
例如,假设您在远程服务器上的代理162.xx.xx.xx
正在侦听 tcp 127.0.0.1:3128
。现在您可以使用以下命令通过 ssh 连接到它:
ssh -p 25512 -L 3128:127.0.0.1:3128 -C 162.xx.xx.xx
Run Code Online (Sandbox Code Playgroud)
这将打开从您的客户端到127.0.0.1:3128
远程主机的隧道127.0.0.1:3128
。然后你可以简单地在客户端上设置你的浏览器来使用代理127.0.0.1:3128
,然后通过 ssh 隧道到远程主机并传递到那里的代理。
该-C
参数启用压缩,并有望使您的浏览速度更快一些,因为必须传输的数据更少。
这些是的相关部分man 1 ssh
:
-L [bind_address:]port:host:hostport
Specifies that the given port on the local (client) host is to be forwarded to
the given host and port on the remote side. 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 a connection is made to host port
hostport from the remote machine. Port forwardings can also be specified in
the configuration file. IPv6 addresses can be specified by enclosing the
address in square brackets. Only the superuser can forward privileged ports.
By default, the local port is bound in accordance with the GatewayPorts
setting. However, an explicit bind_address may be used to bind the connection
to a specific address. The bind_address of “localhost” indicates that the
listening port be bound for local use only, while an empty address or ‘*’
indicates that the port should be available from all interfaces.
-C Requests compression of all data (including stdin, stdout, stderr, and data for
forwarded X11 and TCP connections). 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.
-p port
Port to connect to on the remote host. This can be specified on a per-host
basis in the configuration file.
Run Code Online (Sandbox Code Playgroud)