INFRASTRUCTURE LEARNINGINFRASTRUCTURE LEARNING
インフラ大全インフラ大全IT INFRASTRUCTURE / LEARNING
Infrastructure learning guide
Find a lesson or lab/

Esc to close · Search terms stay on your device

LEARNING日本語

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.

What you will learn

Use the symptom to distinguish path, controls, host state and authentication, then choose an appropriate next check.

Prerequisite

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

Symptoms guide investigation; they do not prove one unique cause
SymptomInvestigation directionAvoid assuming
TimeoutMethod, target, route, controls and host stateThe SG is not necessarily the only cause
Connection refusedTarget, listener and host or intermediate rejectionThe required service may not be listening
Authentication error such as Permission deniedUser, key, authentication method and permissionsBroader network access is not a universal fix
Host-key verification errorDestination identity and known changesDo 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.

Establish the method before choosing requirements
MethodPrerequisites to inspect
Direct Internet SSHPublic-side addressing, route, scoped controls, SSH listener and authentication
EC2 Instance Connect EndpointCompatible endpoint, IAM permissions, SGs and connection-method prerequisites
Normal Session Manager shellIAM and managed-node/agent prerequisites; do not assume opening inbound port 22 is required
Identify the method, then follow the relevant checks
Identify the method, then follow the relevant checks1: Method and target — Review requirements for this particular method — Path and controls. 2: Path and controls — Separate traffic requirements from host requirements — Listener and identity12Method and targetPath and controlsListener andidentityIdentify the method, then follow the relevant checks1: Method and target — Review requirements for this particular method — Path and controls. 2: Path and controls — Separate traffic requirements from host requirements — Listener and identity12Method andtargetPath andcontrolsListener andidentity
  1. Method and target → Path and controlsReview requirements for this particular method
  2. 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

  1. Verify the instance state, connection method, target address and port.
  2. Inspect the applicable route tables, gateway or management path.
  3. Inspect actual SG associations and the required NACL directions.
  4. 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.

A connection times out. Should you first add public IPs and world-open port 22 to every configuration?
Read the answer and reason

Answer: Identify the method and required path first · A private management path has different prerequisites from direct public SSH. Establish the method, target and symptom before choosing scoped checks.

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

  1. Identify the method and error category.
  2. Separate path, controls, host and authentication.
  3. 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.