Recently I was finding that my SSH connection to my FreeBSD server was freezing. I’m on macOS Catalina connecting to a FreeBSD box using standard Terminal app. I’m using shared keys and the connection was fine and working well until I left the Terminal window idle for over 15 seconds.
To prevent your connection from freezing simply create local SSH config file:
# cd ~/.ssh # touch config
And add ServerAliveInterval option to it:
# echo "ServerAliveInterval 60" >> ~/.ssh/config