Reputation: 11
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
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
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
Reputation: 1189
You need to check for the following steps in order to connect EC2 from Mac:
First download the pem file used / created at the time of instance creation.
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.
Now change the permission of the file to Read / Write and make sure the file extension is .pem and not .txt
Check the EC2 permission weather the port is being enabled or not using the following sub steps:
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