Desde la máquina Windows usando la consola CLI (cmd):
ssh USER@HOST "tcpdump -s 0 -U -n -w - -i NETIF FILTER" | "c:\Program Files\Wireshark\Wireshark.exe" -k -i -
# USER - remote user of the linux box
# HOST - host address of the remote linux box
# NETIF - network interface to snif in the remote linux box
# FILTER - (optional) rules for filtering traffic to capture
Caso de uso:
C:\Windows\System32\OpenSSH>ssh root@192.168.4.74 "tcpdump -s 0 -U -n -w - -i eno2 udp and not port 53" | "c:\Program Files\Wireshark\Wireshark.exe" -k -i -
Déjame presentar un caso de uso poco habitual de este truco tan útil. Uso un QNAP NAS como puerta de enlace en mi red de casa, donde tengo 5 NICs. Así pues, es muy útil capturar tráfico de forma remota, pero no tengo ningún paquete de tcpdump en el sistema. Lo que hice fue usar tcpdump como contenedor de Docker y finalmente el comando queda así.
# sniffing SIP traffic (port 5060) on interface eth0
# remote linux host (QNAP NAS) use SSH port 55222
# docker container is created and when work is done is removed
C:\Windows\System32\OpenSSH>ssh -p 55222 admin@10.2.0.1 "cd /share/Container/tcpdump && docker run --rm --net=host corfr/tcpdump -s 0 -U -n -w - -i eth0 not port 22 and port 5060" | "c:\Program Files\Wireshark\Wireshark.exe" -k -i -
Nota personal:
ssh -p 55222 admin@10.2.0.1 "docker run --rm --net=host corfr/tcpdump -s 0 -U -n -w - -i qvs0 host 10.2.0.177" | "c:\Program Files\Wireshark\Wireshark.exe" -k -i -