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

0 votes

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 in AWS by akhtar
• 11,270 points
165 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 by MD
• 24,500 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,630 points
960 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
• 57,530 points
6,222 views
0 votes
1 answer
0 votes
1 answer