user278618
user278618

Reputation: 20262

Store and read a private key in appsettings.json

We are not allowed to store private keys in our repository so we place it in octopus and replace it in it. We use the key to connect with an external sftp server Copying the value to octopus I loose the line feed character LF. When I read and use it later I get an error, that the key is invalid. What would be the best way to read or store the key?

Upvotes: 1

Views: 1330

Answers (1)

X3R0
X3R0

Reputation: 6327

Convert the private key to Base64 before storing it in Octopus. This encoding will preserve all characters, including LF. When you retrieve the key from Octopus, decode it from Base64 back to its original format, and you should have the LF preserved.

Double-check the format of the private key when you read it from Octopus. Make sure it matches the expected format for SFTP connections. For example, SSH keys typically have specific header and footer lines like -----BEGIN RSA PRIVATE KEY----- and -----END RSA PRIVATE KEY-----

Upvotes: 4

Related Questions