[AWS] SSH connection to EC2 timed out, prompt: connect to host ec2-XXX.compute-1.amazonaws.com port 22: Connection timed out

Table of contents

0. Environment

1. Cause of the problem

2. Solution steps 


0. Environment

windows 11 64 bit

1. Cause of the problem

When using SSH to connect to the EC2 instance, an error is reported: [connect to host ec2-23-20-123-143.compute-1.amazonaws.com port 22: Connection timed out]

Pinging my EC2 also prompts that the request timed out

Based on this, it should be a problem with port rules (because my SSH service is enabled) but I still can't connect

So you need to add inbound rules in EC2 and open port 22 (actually I opened two ports 22 and 80)

2. Solution steps 

Solution: In the [Security Group] of EC2, add new rules

The specific steps to create a new rule are as follows:

First log in to your AWS account, IAM is fine, in the service, select EC2

At this point, I have created an EC2 instance and it is running. Click to enter [Security Group]

After entering the security group, you can see that I have a default rule [default]. At this time, you can choose [create a new security group], or [edit the default security group to add inbound rules]. I chose the latter method , add inbound rules in default

Check the security group name, click [Operation], click [Edit Inbound Rules]

Click [Add Rule] to add a rule. I added the following two rules:

1) The type is HTTP, the protocol is TCP, the port range is 80, and the source is "anywhere-IPV4"

2) The type is HSSH, the protocol is TCP, the port range is 22, and the source is "anywhere-IPV4"

After inputting, click [Save Rules]

So far, the port configuration has been added and completed. Use SSH to connect to EC2 again in the command line and find that the connection can be successful.

--END--

Guess you like

Origin blog.csdn.net/qq_41539778/article/details/132667053