To keep your ssh session alive thus preventing to being locked out when the firewall is reloaded or whatever add a ‘config’ file to you local .ssh directory.

$ cat .ssh/config
Host *
ServerAliveInterval 60

Now your session is will be kept alive.