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,180 points
1,522 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,140 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,650 points
1,576 views
+1 vote
3 answers

Log in to AWS using Access Key ID and Secret Access Key ID

Access keys consist of an access key ...READ MORE

answered Aug 17, 2018 in AWS by Priyaj
• 58,100 points
13,757 views
0 votes
1 answer
0 votes
1 answer