MITM 攻撃を回避するために SSH トンネルを使用する方法は?

MITM 攻撃を回避するために SSH トンネルを使用する方法は?

一般的な家庭用ルーター内にコンピューターがあるとします (ただし、ルーターへのファイアウォール/ポート転送アクセスは利用できません)。その内部 IP は 192.168.1.81 である可能性があります。その LAN 上には、IP 192.168.1.85 を持つ攻撃者のマシンがあり、192.168.1.81 に対して一般的な ARP スプーフィング MITM 攻撃を実行しようとしています (urlsnarf などを実行して、訪問した Web サイトをスニッフィングするとします)。192.168.1.81 マシンは、Chrome でインターネットを閲覧する際に、あらゆる形式の MITM 攻撃を防ぎ、安全を確保したいと考えています。攻撃者は、攻撃者が MITM 攻撃でスニッフィングできないように、Web 閲覧を暗号化するために SSH アクセスを備えたサーバーを所有しています。私 (SSH トンネリングを使用して安全を確保したいユーザー) は、自分のサーバー (パブリック IP 162.xx.xxx.xx) で SSH トンネリングを使用して、潜在的な MITM 攻撃を防ぐにはどうすればよいですか? これは科学フェアのプロジェクトです。サーバーでどのような設定を行う必要がありますか (完全なルート アクセス権を持っています)? SSH ポートは標準と異なるため、SSH ポート 25512 を参照にしてください。また、サーバーのファイアウォールでポート 4567 を開いているため、そのポートも参照に使用してください。ホーム ネットワークのパブリック IP として 72.xxx.xx.xxx を使用してください。必要なコマンドをすべて含めてください。より明確にする必要がある場合はお知らせください。ご協力いただける方は、どうぞよろしくお願いいたします。

答え1

最も簡単な方法は、リモート サーバー上でプロキシ (たとえば squid) を実行し、ローカル インターフェイスでのみリッスンするようにすることです127.0.0.1(インターネットへのプロキシを開きたくないため)。

次に、リモート サーバーに SSH 接続し、リモート サーバー上のローカル プロキシ インターフェイスへの TCP 転送を作成します。

たとえば、リモート サーバー上のプロキシが162.xx.xx.xxtcp でリッスンしているとします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パラメータにより圧縮が有効になり、転送するデータが少なくなるため、ブラウジングが少し速くなるはずです。

以下は、次の関連部分です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.

関連情報