Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (12.9k points)

I created a micro ec2 instance. Installed all the necessary web software, mysql and git. Created an AMI out of that instance. Since that instance was using EBS as its root device, it took an EBS snapshot as well when I was creating my AMI.

I terminated that running instance. I then tried creating an instance out that amazon machine image (AMI), the new instance started along with a new EBS volume getting attached to the instance.

Now when I use my key pair to login to that instance via my ssh key to its public DNS address with a command as

ssh -i aws/mykey.pem ubuntu@thepublicdnsname

it says

ssh: connect to host <thepublickdnsname> port 22: Connection refused

Why is this happening. I was able to connect to my first instance with the same keys via ssh. Now the new instance is the exact copy and im not able to login to it. Any help on this? Am I missing something?

I used the same key pairs to create the second new instance from the AMI.

1 Answer

0 votes
by (18.2k points)

I was in the situation and found out that it can take a variable amount of time for the EC2 instance to get initialized. Just give it a few minutes(let the state change from pending to running and let it get initialized). After that, you'll be able to SSH into the instance without any trouble.

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...