I have an ssh connection that I run to access a remote machine. At present I use autossh to keep the pipe open 24/7.

I am curious as to how much the pipe alone uses bandwidth wise. How can I measure something like this?

note: It is rarely used but handy so it just sits there. So I can make sure nothing is sent for a day while taking measurements if needed.

  • 1
    Might want to say which operating systems are at the end of each end of the ssh connection. Commented May 14, 2012 at 22:35
  • @EightBitTony I didn't realise this was of importance seeing it's the same protocol but it's OSX 10.6.8 <----> Ubuntu 12.04
    – dibs
    Commented May 14, 2012 at 22:49
  • 2
    I only suggest it, because some tools might not be available on some operating systems. i.e. now we know there's no point anyone suggesting a tool for Windows. Commented May 14, 2012 at 23:04
  • @EightBitTony Ah excellent point!
    – dibs
    Commented May 14, 2012 at 23:26

1 Answer 1


This could be done with iptables rules to count the packets. I'm assuming that the server is running Ubuntu, so you'd want something like this (assuming that your client's IP is

iptables --insert INPUT 1 --protocol tcp --dport 22 --source -j ACCEPT
iptables --insert OUTPUT 1 --protocol tcp --sport 22 --destination -j ACCEPT

Running iptables -nvL will show the number of packets and total size of packets caught by those rules -- add them up to get the total.

  • 1
    Agreed, also I believe one could specify a LOG target and then parse the log files periodically. Obviously not viable for high-traffic environments, but it could be useful.
    – EEAA
    Commented May 14, 2012 at 23:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .