This glitch is pretty annoying. You’re following a log, while connected to a server (through ssh), and after a while, your ssh connection hangs.
Fire up Terminal, and type the following: nano ~/.ssh/config
Once there, fill up the following:
That should keep your connection alive for the next 10 hours, without further issues.