Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Might want to say which operating systems are at the end of each end of the ssh connection. – EightBitTony May 14 '12 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 May 14 '12 at 22:49
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. – EightBitTony May 14 '12 at 23:04
@EightBitTony Ah excellent point! – dibs May 14 '12 at 23:26
up vote 2 down vote accepted

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.

share|improve this answer
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 May 14 '12 at 23:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.