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.