I set a remote capture to a host using
and tried some variations that resulted in · no packets being read by Wireshark Redirecting to a simple file does work but not in a format Wireshark can read later. When Wireshark threw an error regarding libpcap format, I also tried clipping the first line that's passed before the raw packets, to no avail though.
EDIT TL;DR asked 20 Jan '16, 12:25 wsk edited 14 Feb '16, 06:28 |
4 Answers:
You are probably writing to a regular file /tmp/remotecapture.fifo. So, did you create a named pipe with?
If no, please do so before you write to it with tcpdump, plus: let Wirshark read from the fifo first.
BTW: make sure, that the SSH command does not write STDOUT messages into the fifo, as Wireshark would not be able to read that! See also:
Regards answered 20 Jan '16, 13:48 Kurt Knochner ♦ |
ssh sucks. Truly, ssh sucks. If you run a command on a remote machine that writes to the standard output and error, both the standard output and the standard error of the command get sent to the local ssh command's standard output! This means that tcpdump's "hi, I'm capturing" message, which it sends to the standard error, gets sent to ssh's standard output, which means it gets written into the middle of your capture file. So try discarding the extra "hi, I'm capturing" message:
answered 26 Jan '16, 16:53 Guy Harris ♦♦ Thanks for pointing that out. I did try clipping the first line, but redirecting to null on the remote host is the right way. That said, I only see a couple of (27 Jan '16, 02:57) wsk Did you actually try this with (29 Jan '16, 18:19) wsk
Yes. (29 Jan '16, 18:36) Guy Harris ♦♦ It still doesn't work for me. In case it's something to factor in, I ssh from a host running OS X to a guest vm running Ubuntu, and between Ubuntu vm guests. Any ideas on how could I further troubleshoot this? (02 Feb '16, 01:57) wsk I have just tried the following:
After logging in, waiting for some traffic to be captured, and then pressing ^C, I've open the test.cap file in Wireshark, and its only complaint was that the file was cut short in the middle of a packet. Can you try the same (and, just for the case that it was not clear, leave a space between the (02 Feb '16, 02:29) sindy
Try running the command (02 Feb '16, 02:35) Guy Harris ♦♦ @sindy, I get the same message, it's still not clear to me where's the problem though. @Guy Harris, with that command the session is immediately closed, The Any ideas? (09 Feb '16, 18:41) wsk
I.e., you get the same "Frame 1 too long" error if you follow @sindy's instructions and then try to open If you do
what are the contents of (09 Feb '16, 18:52) Guy Harris ♦♦ I tested this on Ubuntu Server 14.04.3 LTS. @sindy, if I run the following command
I can open
@Guy Harris, if I run
(11 Feb '16, 15:06) wsk OK. Both tests seem to indicate that there must have been some typo in your original attempts, because:
But there is still some space left for doubt.
So please repeat both tests above with additional parameter of tcpdump, If the result of "my" test is a file of 50 packets about which Wireshark does not complain, and the result of @Guy Harris' test is still a 0 B file, you know for sure that both tcpdump and ssh are OK if you use tcpdump with Finally, try again with the named pipe, first also with the (11 Feb '16, 22:31) sindy If I run
the resulting file can be opened in Wireshark without the 'packet cut short' warning. If I run
the resulting file has size 0B. If I leave out option
And with a non-root account use this
I couldn't find a better alternative for the latter, please let me know your suggestions. Instead of option For the sake of readability I added a tl;dr to my question. (14 Feb '16, 06:23) wsk showing 5 of 11 show 6 more comments |
There is also the 2.1.x extcap plugin sshdump that runs tcpdump or dumpcap remotely at the end of an ssh tunnel, although that only seems to work on linux at the moment. answered 02 Feb '16, 05:32 grahamb ♦ More detailed info about this plugin, or extcap in general for that matter, seems hard to come by. Will this ever be available for other systems? (09 Feb '16, 18:48) wsk Unfortunately user visible documentation for extcap is still lacking, despite requests. There is README.extcap in the sources\docs directory. Basically extcap allows plugin processes external to Wireshark to provide "capture" interfaces. The sshdump plugin makes an ssh connection to the remote machine, runs tcpdump\dumpcap and provides the returned packets to Wireshark. To make it run on OSX would require some work on the OSX build machine to add libssh (presuming there is a version of the library that runs on OSX), and the Windows version will compile but I can't persuade it to actually capture successfully, see change 12117. (11 Feb '16, 07:43) grahamb ♦ Thanks for the reference. (11 Feb '16, 15:15) wsk
(12 Feb '16, 02:24) grahamb ♦ |
Seeing as this is actually fairly recent... For what it's worth, I'll leave here my preferred one-liner solution for live remote capture on non-standard ssh ports using Windows' version of wireshark and standard tcpdump on whatever flavor of Linux the remote machine has. It doesn't use the questionable plink (whose main disadvantage is that its flags don't map over to the far more widespread ssh's...), but instead relies on cygwin/standard ssh command. It doesn't strictly require you to use a key to authorize, but if you don't, it stops being a one-liner. Also, it isn't hugely efficient in that some of the packets get lost to whatever perils there exist in ssh tunnels. Yet it allows you to benefit from the convenience of Windows Wireshark while utilizing the power of Linux's tcpdump. I experimented with opening remote/local tunnels seeking to capture and display all the packets that came, even if they would be displayed with a delay, and so far this so the most accurate representation. Still, not ALL the packets show up on the capture, compared to a local file tcpdump dump. For various reasons of convenience, I can't / don't want to use named pipes unless they can be incorporated into a one-liner. The quest continues. (Unconvinced about gzip|gunzip, but so far my tests show that fewer packets get lost this way, at the cost of speed and latency of course. Looking into stdbuf at the moment.) Anyway, using cygwin with standard packages and either replacing or defining anything in caps, you'd run:
If you use the standard port 22, it gets simpler:
If you encounter a problem with some packets getting lost, inexplicably, I've found that answered 17 Apr '16, 02:22 katzurki edited 17 Apr '16, 06:32 Are you really missing packets, or is just the delayed line buffering? (28 Jun '16, 11:15) wsk |
I made sure it was a
named pipe
, but nonetheless followed the steps you described and still have similar results.and get the following messages
click on ok, next
If I check this locally, I see the following output
I don't know what else
ssh
could be passing along.Did you actually try this with
tcpdump
? Btw, I used OpenSSH_5.9p1 and OpenSSH_6.6.1p1.