analyze traffic remotely over ssh w/ wireshark

ssh root@server.com 'tshark -f "port !22" -w -' | wireshark -k -i -
This captures traffic on a remote machine with tshark, sends the raw pcap data over the ssh link, and displays it in wireshark. Hitting ctrl+C will stop the capture and unfortunately close your wireshark window. This can be worked-around by passing -c # to tshark to only capture a certain # of packets, or redirecting the data through a named pipe rather than piping directly from ssh to wireshark. I recommend filtering as much as you can in the tshark command to conserve bandwidth. tshark can be replaced with tcpdump thusly: ssh root@example.com tcpdump -w - 'port !22' | wireshark -k -i -

30
By: markdrago
2009-12-17 23:03:24

6 Alternatives + Submit Alt

What Others Think

This work for me but you must to install tshark on the remote machine and wireshark on the local machine and the "port !22" gets an error, I try without the "!" and runs. In my Ubuntu Server I must include the "sudo" command. I use like this for the webtrafic: ssh user@remotehost 'sudo tshark -f "port 80" -w -' | wireshark -k -i - Thanks!
kutus · 443 weeks and 3 days ago
same as here but add `-Fpcap` to the remote `tshark`. Got error from wireshark about not accepting pcapng in stdin
nhed · 16 weeks and 2 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: