如何通过SSH隧道来避免MITM攻击?

说我有一个典型的家庭路由器内的电脑(但说防火墙/端口转发访问路由器不可用)。 它的内部IP可以是192.168.1.81。 在那个局域网上有一个攻击者机器,IP 192.168.1.85想要在192.168.1.81上做一个典型的ARP欺骗MITM攻击(比如说他想运行一些类似urlsnarf的东西来窥探访问过的网站)。 这台192.168.1.81的机器想要阻止任何forms的MITM攻击,并在Chrome上浏览互联网时保持安全。 他有一个SSH访问服务器,他想用它来encryption他的网页浏览,所以攻击者无法用MITM攻击来嗅探它。 我如何(希望使用SSH隧道的用户保持安全)在我的服务器(公共IP 162.xx.xxx.xx)上使用SSH隧道来防止潜在的MITM攻击? 这是一个科学公平的项目。 我必须在我的服务器上做什么(如果有的话)设置(我有完全的root权限)? 我的SSH端口不同于常规,所以请以SSH端口25512为参考。 我也在服务器的防火墙上打开了端口4567,所以请使用该端口作为参考。 请使用72.xxx.xx.xxx作为家庭networking的公共IP。 请包括任何必要的命令。 让我知道如果我需要更清楚。 非常感谢任何能够帮助的人!

最简单的方法是在远程服务器上运行一个代理服务器(fe squid),并使其仅在本地接口127.0.0.1上进行监听(因为您不想打开代理服务器到Internet)。

然后你ssh进入远程服务器,并创build一个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 

这将打开从客户端127.0.0.1:3128到远程主机127.0.0.1:3128的隧道。 然后,您可以简单地在客户端上设置您的浏览器使用代理127.0.0.1:3128 ,然后通过SSH隧道到远程主机,并在那里传递到代理。

-C参数启用压缩function,希望能让浏览速度更快一些,因为传输的数据较less。

这些是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.