【问题标题】:How to remotely capture traffic across multiple SSH hops?如何远程捕获跨多个 SSH 跃点的流量?
【发布时间】:2017-05-11 17:51:48
【问题描述】:

我想调试我网络上的另一台机器,但必须通过一个或多个 SSH 隧道才能到达那里。

目前:

    # SSH into one machine
    ssh -p 22 me@some_ip -i ~/.ssh/00_id_rsa

    # From there, SSH into the target machine
    # Note that this private key lives on this machine
    ssh -p 1234 root@another_ip -i ~/.ssh/01_id_rsa

    # Capture debug traffic on the target machine
    tcpdump -n -i eth0 -vvv -s 0 -XX -w tcpdump.pcap

但是随后将.pcap 连续复制出来很痛苦。有没有办法将 pcap 直接写入我安装了 wireshark 的本地机器?

【问题讨论】:

    标签: ssh wireshark tcpdump


    【解决方案1】:

    您应该使用ProxyCommand 链接 ssh 主机并将 tcpdump 的输出直接通过管道传输到wireshark。为此,您应该创建以下 ssh 配置文件:

    Host some_ip
      IdentityFile ~/.ssh/00_id_rsa
    
    Host another_ip
      Port 1234
      ProxyCommand ssh -o 'ForwardAgent yes' some_ip 'ssh-add ~/.ssh/01_id_rsa && nc %h %p'
    

    我用全路径测试过,所以要小心~

    要查看实时捕获,您应该使用类似

    ssh another_ip "tcpdump -s0 -U -n -w - -i eth0 'not port 1234'" | wireshark -k -i -
    

    如果您只想在本地转储 pcap,您可以将 stdout 重定向到您选择的文件名。

    ssh another_ip "tcpdump -n -i eth0 -vvv -s 0 -XX -w -" > tcpdump.pcap
    

    另见:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-11-05
      • 2013-05-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多