ssh client hang after a few minutes of inactivity

specify the parameter “ServerAliveInterval 60” in /etc/ssh_config or /etc/ssh/ssh_config.

for more info, man ssh_config