How much data does SSH typically use?

25

4

I want to ssh into a laptop (Ubuntu) which will be connected through a 3G connection. Therefore I need to estimate how much data I will be using to choose a suiting plan.

Separate from file transfer, for which I can easily determine how much data will be used, what is the typical amount that an ssh session uses? Is there some sort of relation, e.g. that using ls on a directory with 50 items will cost me a certain amount of data? Or is it more time dependent and does an ssh session transmit a certain amount of data per time interval, regardless of use?

Saaru Lindestøkke

Posted 2013-07-26T21:56:41.110

Reputation: 1 275

Answers

15

what is the typical amount that an ssh session uses?

I'm not sure there is "typical"

You should run tcpdump -ni eth0 -w dump port 22 to capture all your packets, then tcpdump -nX -r dump to view them.

Is there some sort of relation, e.g. that using ls on a directory with 50 items will cost me a certain amount of data?

You could compute that. As a rough estimate, every keystroke will generate 4 packets (keypress, ack, echo on screen, ack) and each packet will have tons of overhead. (My TCP dump says 500 bytes to type 2 characters.)

My directory listing of 135 files took 2.5k.

Using ssh -C compression should help for the bigger text.

Or is it more time dependent and does an ssh session transmit a certain amount of data per time interval, regardless of use?

Yes. Both TCP and SSH have keepalive probes. This will be an issue if you keep it up all the time. Again, use TCPDump to measure.

My advice: instead of worrying, make sure you actually have realtime feedback on your usage. After you use a few sessions, you'll be able know how close you are.

BraveNewCurrency

Posted 2013-07-26T21:56:41.110

Reputation: 286

1To find the total size of the packets captured by tcpdump, one can use capinfo (from Wireshark) on the file written by tcpdump. e.g. capinfos dump – Flux – 2019-06-19T14:06:12.263

8

I have a similar setup (3G connection on a remote Ubuntu laptop).

While I agree there is no "typical" answer (it depends both on your own usage, as well as sshd/ssh options like "keepalive" frequency, ssh compression & perhaps other ssh options), I've been able to reduce my basic idle ssh bandwidth to 0.2 - 0.3MB / hour (works out to 200MB/month).

I've used tcpdump and then wireshark to visualise and measure my bandwidth usage (in addition to the interface's RX bytes/TX bytes using ifconfig).

0.2 - 0.3MB bandwidth on my rig is with the following options: TCPKeepAlive no (sshd server, sshd_config) and ServerAliveInterval 180, ServerAliveCountMax 40, TCPKeepAlive no (on the client, i.e. ssh_config)

Hope this helps, if not you, then other users with a similar setup.

Geehan

Posted 2013-07-26T21:56:41.110

Reputation: 81

3

SSH is basically sending the command and the screen output. If you're just doing command line stuff, a rough estimate would be a byte per character on your screen.

Obviously, if you tunnel an X session, SCP to transfer files, etc, the bandwidth will go up.

I say it's a rough estimate as there's some overhead. You can also use the -C flag to request compression.

ernie

Posted 2013-07-26T21:56:41.110

Reputation: 5 938

2

if you want to mesure how much bandwith ssh is using

use iftop and filter it on port that ssh use (22)

http://tournasdimitrios1.wordpress.com/2011/01/20/iftop-monitor-and-analyze-your-network-traffic-on-linux/

xreact

Posted 2013-07-26T21:56:41.110

Reputation: 49