
To solve this, we analyse the $SSH_CLIENT environment variable to specifically exclude the packets of the current SSH session from being returned.

If you were going to run this script on your local computer, these three arguments would be sufficient.īut there’s an added hurdle when running the script over SSH.īecause it logs all network traffic, each packet sent will result in some more SSH traffic - which then gets captured by the script itself, and sent over SSH, which gets captured, and sent, and so on, ad infinitum.

The -U flag disables buffering, so captured packets are shown immediately.
