1 way: you local computer

You can set a keep alive option in your ~/.ssh/config file on your computer's home dir:

ServerAliveInterval 50

Amazon AWS usually drops your connection after only 60 seconds of inactivity, so this option will ping the server every 50 seconds and keep you connected indefinitely.

2 way: your instance settings

Assuming your Amazon EC2 instance is running Linux (and the very likely case that you are using SSH-2, not 1), the following should work pretty handily:

Remote into your EC2 instance.


    ssh -i <YOUR_PRIVATE_KEY_FILE>.pem <INTERNET_ADDRESS_OF_YOUR_INSTANCE>

Add a "client-alive" directive to the instance's SSH-server configuration file.


    echo 'ClientAliveInterval 60' | sudo tee --append /etc/ssh/sshd_config

Restart or reload the SSH server, for it to recognize the configuration change.

The command for that on Ubuntu Linux would be..


        sudo service sshd restart

Disconnect.

logout

The next time you SSH into that EC2 instance, those super-annoying frequent connection freezes/timeouts/drops should hopefully be gone.