Many time shell remain idle and due to that SSH connection get closed by server and you need to relogin to the shell.
You will able to avoid this problem by increasing timeout in "sshd_config" configuration file.

Edit sshd_config file on the server and search for "ClientAliveInterval" parameter.

Code:
[email protected] [~]# cat /etc/ssh/sshd_config | grep ClientAliveInterval
#ClientAliveInterval 0
Edit file using any favorable editor.

Code:
[email protected] [~]#vi /etc/ssh/sshd_config
Make below changes in the file.

From
Code:
#ClientAliveInterval 0
To
Code:
ClientAliveInterval 7200
Save the changes and restart the sshd service.

Code:
[email protected] [~]# /etc/init.d/sshd restart
So that ssh connection never get disconnected for 7200 seconds.