How much data does SSH typically use?
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?
Solution 1:
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.
Solution 2:
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.