Topic lessonTopic: VPC: routing and traffic controls
Cannot SSH to EC2? Diagnose timeouts, refusal and authentication errors
When SSH to EC2 fails, first identify the connection method and error category. A timeout, a refusal and an authentication error lead to different checks. Establish the intended destination and path before adding public addressing or broad SG rules.
Use the symptom to distinguish path, controls, host state and authentication, then choose an appropriate next check.
Know basic VPC, SG and NACL concepts. Do not paste private keys, signed URLs or real network logs into this site.
Classify the observed failure first
| Symptom | Investigation direction | Avoid assuming |
|---|---|---|
| Timeout | Method, target, route, controls and host state | The SG is not necessarily the only cause |
| Connection refused | Target, listener and host or intermediate rejection | The required service may not be listening |
| Authentication error such as Permission denied | User, key, authentication method and permissions | Broader network access is not a universal fix |
| Host-key verification error | Destination identity and known changes | Do not bypass host verification |
An error is not by itself proof that you reached the intended EC2 instance or satisfied every network condition. Compare the hostname or IP, port and expected destination with the peer actually contacted.
Connection methods have different prerequisites
Direct Internet SSH, VPN or bastion access, EC2 Instance Connect Endpoint and Session Manager administration have different prerequisites. Identify the method in use. A normal Session Manager shell session does not use the same diagnostic path as direct SSH authentication.
| Method | Prerequisites to inspect |
|---|---|
| Direct Internet SSH | Public-side addressing, route, scoped controls, SSH listener and authentication |
| EC2 Instance Connect Endpoint | Compatible endpoint, IAM permissions, SGs and connection-method prerequisites |
| Normal Session Manager shell | IAM and managed-node/agent prerequisites; do not assume opening inbound port 22 is required |
- Method and target → Path and controlsReview requirements for this particular method
- Path and controls → Listener and identitySeparate traffic requirements from host requirements
- Method and target
- Which path, which host and which port?
- Path and controls
- Inspect the relevant request/response route, SGs and NACLs.
- Listener and identity
- Inspect host state, SSH listener, user and authentication method.
For timeouts, inspect the path and its boundaries
- Verify the instance state, connection method, target address and port.
- Inspect the applicable route tables, gateway or management path.
- Inspect actual SG associations and the required NACL directions.
- Review local/corporate controls, host firewall, listener and relevant load conditions.
NACL review involves not just the destination SSH port but the client port used for the response. Establish the required range for the method and client. An inbound port-22 rule does not establish every return-path requirement.
Keep listeners and authentication separate from network grants
For authentication errors, use an authorized management path to review the username appropriate to the AMI or user, expected key or method and file permissions. A .pem filename does not establish the correct key or safe permissions.
Choose an option to see the result and explanation.
The VPC lab teaches a subset of path conditions
The site’s VPC lab compares synthetic IPv4/TCP conditions within one VPC. It does not test real SSH, private keys, listeners or the actual management method. A satisfied model is not evidence of a successful SSH connection.
Check, then explain in your own words
- Identify the method and error category.
- Separate path, controls, host and authentication.
- Do not replace investigation with broad exposure or disabled verification.
Check your understanding: The path model is satisfied, but SSH fails. Is that a contradiction?
Conditions outside the model remain.
The method, OS, listener and authentication remain untested by the lab. Bounded conditions and real SSH success are different evidence.
Sources and conditions checked
The official references used in this lesson are collected here with their scope, conditions and corresponding sections. Independent expert review and live AWS comparison have not been performed.
Scope and conditionsConnection mode, network, host and authentication must be separated
Used in this lessonClassify the observed failure first Connection methods have different prerequisites For timeouts, inspect the path and its boundaries Keep listeners and authentication separate from network grants
- VPC security groupsChecked:
Scope and conditionsStateful resource traffic controls
Used in this lessonConnection methods have different prerequisites For timeouts, inspect the path and its boundaries
- VPC network ACLsChecked:
Scope and conditionsStateless subnet boundary controls; rule order and return traffic
Used in this lessonConnection methods have different prerequisites For timeouts, inspect the path and its boundaries
- VPC route tablesChecked:
Scope and conditionsDestination/target and subnet associations
Used in this lessonConnection methods have different prerequisites For timeouts, inspect the path and its boundaries
- Network ACL rulesChecked:
Scope and conditionsDirection, protocol, port, peer CIDR and first matching rule in ascending order.
Used in this lessonFor timeouts, inspect the path and its boundaries
Scope and conditionsMethod-specific endpoint, IAM, security-group and instance prerequisites; no endpoint is created or contacted here.
Used in this lessonConnection methods have different prerequisites
Scope and conditionsNormal managed shell sessions and their IAM/managed-node assumptions, distinct from direct SSH and SSH tunneling.
Used in this lessonConnection methods have different prerequisites