jvera
jvera

Reputation: 11

AWS EC2 closed my port 22

i have a problem, im trying to connect to my instance EC2 with SSH, but say: Connection closed by IP port 22

I was checking all the configuration, im using a Mac with iTerm (also try with terminal) and is not working, looks like AWS EC2 block my Key PEM.

I ask to AWS support, but they said my IP is not block and they dont see any problem...

What I try is open my port 22, enable the remote login, change the permission to my pem.

Also I configure my inbound connection, with the same configuration of another instance and is working.

I was searching for a solution, but I don't have a solution, maybe I can create another instance and move the content to another instance, but I don't know if I can do that?

any information will be helpful

Upvotes: 1

Views: 8131

Answers (3)

Sahil Bhatia
Sahil Bhatia

Reputation: 61

After many days of struggling with this issue i found solution. You just have to stop your instances and de-attach your volumes and reattach them and it will work like charm. Hope it help you out.

Upvotes: 0

mathfac
mathfac

Reputation: 196

Check that the username was incorrect. On ubuntu instances it should be "ubuntu" and on amazon instances it should be "ec2-user".

Upvotes: 10

Mohd Belal
Mohd Belal

Reputation: 1189

You need to check for the following steps in order to connect EC2 from Mac:

  1. First download the pem file used / created at the time of instance creation.

  2. We have a benefit using Linux / Mac over windows as PEM file created can directly be used to connect. For windows we need to convert it into PPK file.

  3. Now change the permission of the file to Read / Write and make sure the file extension is .pem and not .txt

  4. Check the EC2 permission weather the port is being enabled or not using the following sub steps:

    1. Check the Routes Table for port 22 incoming request is allowed or not.
    2. Check the Network Access Control List of the VPC at the subnet weather the incoming request at port 22 is allowed or not.
    3. Check the Security Group of the instance that weather port 22 request is allowed or not.

By default all the incoming request is being Blocked by the AWS. And we need to enable the port with the corresponding protocol to allow or not.

If you have no idea then simply you can set the permission to ALL REQUEST to 0.0.0.0/0, this will enable to connect your EC2 to the internet and to your ssh as well.

Hope this helps.

Upvotes: 0

Related Questions