I'm experiencing this weird issue, where I can SSH connect to a new EC2 instance for couple seconds then the connection will drop by itself and once it is dropped I can no longer reconnect while the EC2 instance is still shown running on AWS Management Console.
Note that I use AWS Management Console to create a Default VPC, and I double checked that:
- I use the public IP and also tried associating an elastic ip.
- the Security Group is allowed inbound traffic on port 22 for my IP.
- The VPC route table has a route of forwarding all traffic 0.0.0.0/0 to the internet gateway
- Network ACL has allow all port, all protocol on 0.0.0.0/0
- And the subnets are associated with the Network ACL
- And IPv4 CIDR is configured and IPv6 CIDR are not.
- And my private key file is correct.
- Verified that Comcast (my ISP) is not block port 22 traffic.
- Tried setting port forwarding/triggering
- I use Amazon Linux 2 AMI (HVM), SSD Volume Type - ami-009d6802948d06e52 (64-bit x86) without any user script and customizations.
- I also tried turning off the router firewall and Windows firewall
I have been trying to resolve this for 3 days now, anything that I missed? any suggest would be greatly appreciated! Here are some more details: VPC: Route Table: Subnets: Subnets Associations: Network ACL inbound ruless Network ACL outbound rules: EC2: Security Group Inbound: Security Group Outbound:
SSH command to connect with gitbash on windows 10 in a path containing my private key: ssh -i "ming-lenovo.pem" [email protected]
As this image shown below, I was connected for couple seconds and disconnected by itself:
127.0.0.1 <yourhostname>
to `/etc/host. In addition, try to use alternate connection such as different ISP / proxy/VPN. Because some ISP may mess up with ssh. – mootmoot