This example set the maximum time to 15 minutes idle, so open sshd_config file with your favorite text editor as root. In our case vi:
vi /etc/ssh/sshd_config
And be sure this options are set:
ClientAliveInterval 900 ClientAliveCountMax 0
This way after 900 seconds, the ssh session will be terminated, with
no keep alive package even being sent. You may adjust the idle time with
ClientAliveInterval, set it in seconds to the time you think is enough for your users.
Also be sure the parameter is enabled:
TCPKeepAlive yes