When you leave an SSH session idle for too long, it may get disconnected. This is usually due to firewalls or network devices dropping idle connections.

To solve this you should edit the ~/.ssh/config file by adding the following line:

ServerAliveInterval 60

So the file's content will be something like:

Host *
	ServerAliveInterval 60

Once saved the modification, if you start a new SSH session it will no longer drop the connection.