1

I have placed pem file as a key value on AWS Secret Manager. When I downloaded the pem file it downloaded as following format.

-----BEGIN RSA PRIVATE KEY-----EncryptedText==-----END RSA PRIVATE KEY -----

How can I convert this to correct pem file format?

The following command I have used to download the secret

secrets=/usr/local/bin/aws secretsmanager get-secret-value --region us-$region --secret-id SecretName --query "SecretString" --output text

echo $secrets | jq '."keyName"'

-----BEGIN RSA PRIVATE KEY-----EncryptedText==-----END RSA PRIVATE KEY -----
Vikash
  • 141
  • 3
  • What do you expect the "correct pem file format" should look like? See https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail –  Aug 02 '19 at 01:03

1 Answers1

2

I assume you want the file to look like:

-----BEGIN RSA PRIVATE KEY-----
EncryptedText==
-----END RSA PRIVATE KEY -----

instead of a one line string.

You can use sed to add new lines:

sed -i -e 's@ KEY-----@KEY-----\n@' -e 's@-----END@\n-----END@' file.pem

-i option modifies the file directly.