Intellipaat Back

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

I want to use my Amazon ec2 instance but faced the following error:

Permission denied (publickey).

I have created my key pair and downloaded .pem file.

Given:

chmod  600 pem file.

Then, this command

ssh -i /home/kashif/serverkey.pem  [email protected]

But have this error:

Permission denied (publickey)

1 Answer

0 votes
by (18.2k points)

There could be various reasons for why your authentication is failing. 

  • First of all, make sure that you are using the correct key pair. I know it sounds trivial but it could actually be an issue in cases like these.
  • Check if the username that you are using is correct or not. For ubuntu based AWS AMIs, the valid username is ubuntu, on others, it's ec2-user.
  • Check if you are connecting to the right host.

Related questions

0 votes
1 answer
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

...