Error Private key must begin with -----BEGIN RSA PRIVATE KEY----- and end with -----END RSA PRIVATE KEY-----

+1 vote

I am trying to connect my EC2 instance via SSH, but it shows me the below error.

Error: Private key must begin with "-----BEGIN RSA PRIVATE KEY-----" and end with "-----END RSA PRIVATE KEY-----"

How can I solve this error?

Apr 28, 2020 in AWS by akhtar
• 38,260 points
11,656 views

1 answer to this question.

0 votes

Hi@akhtar,

If you use a third-party tool, such as ssh-keygen, to create an RSA key pair, it generates the private key in the OpenSSH key format. When you connect to your instance, if you use the private key in the OpenSSH format to decrypt the password, you'll get the error Private key must begin with "-----BEGIN RSA PRIVATE KEY-----" and end with "-----END RSA PRIVATE KEY-----".

To resolve the error, the private key must be in the PEM format. Use the below given command to create the private key in the PEM format.

$ ssh-keygen -m PEM

Hope this will help.

answered Apr 28, 2020 by MD
• 95,460 points

Related Questions In AWS

0 votes
1 answer
+1 vote
2 answers

Starting with an AWS Instance with API and AUTHPARAMS

The API is usually much easier to ...READ MORE

answered Apr 17, 2018 in AWS by Cloud gunner
• 4,670 points
3,861 views
0 votes
1 answer
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP