I have tried multiple instances, have spent all day going through different ways to fix this, but each time I connect via ssh from my macbook to one of my amazon EC2 instances they only work once.
I can usually connect, using the standard ssh -i "FILENAME.pem" ubuntu@ec2-54-174-127-125.compute-1.amazonaws.com
Then, the instance will freeze (usually after 5-20 minutes) and when I try to connect afterwards it will not be responsive and I will get ssh: connect to host ec2-54-174-127-125.compute-1.amazonaws.com port 22: Operation timed out
I have tried modifying my ssh config file, as many internet answers suggest, but it did not help the slightest. I also had the same problem in an Ubuntu VM.
Here is the modified config:
Host *
SendEnv LANG LC_*
ServerAliveInterval 120
I looked at my security groups and did everything that the Amazon guidelines recommend.
Here is a screenshot of the full output:
OpenSSH_7.3p1, LibreSSL 2.4.1
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 20: Applying options for *
debug1: /etc/ssh/ssh_config line 57: Applying options for *
debug2: resolving "ec2-54-89-219-10.compute-1.amazonaws.com" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to ec2-54-89-219-10.compute-1.amazonaws.com [54.89.219.10] port 22.
debug1: connect to address 54.89.219.10 port 22: Operation timed out
ssh: connect to host ec2-54-89-219-10.compute-1.amazonaws.com port 22: Operation timed out
Can you please help?
Thanks,
Tim