I’m not sure if I’m the only one that experiences this but SSH on MacOS seems to have awful keep-alive out of the box. Connections constantly hang when I look away for more than a few minutes. So I can recommend this change in your SSH config:
# /etc/ssh/ssh_config
Host *
ServerAliveInterval 30