Intellipaat Back

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

This seems to be a common problem but my specific case seems a little different.

I set up a new Amazon EC2 instance using the command line tools and connected via SSH and did some configuration work.

Initially, though, I couldn't ssh on to the instance, I had to stop and restart the instance, then i could connect. Before restarting I just got the response.

Permission denied (publickey)

That was last night, this morning I go back to the same instance and now all I get is

Permission denied (publickey)

I've tried rebooting the instance with no joy.

Can anyone point me in the right direction here? The same command that worked last night no longer works, I'm connecting from my Macbook Pro.

1 Answer

0 votes
by (18.2k points)

Try the following command:

ssh -i ~/.ssh/[keypair name] ec2-user@[ec2 instance ip]

This should get you in. Remember to use the login user name according to the OS in your instance. 

For Ubuntu-based machines use: ubuntu

For Debian: admin

For Centos: centos

For Amazon Linux: ec2-user

For the rest of the machine types, use ec2-user

Related questions

Want to get 50% Hike on your Salary?

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

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...