The title may be a bit confusing, so a little explanation.
I need to configure an application by passing a PKCS1 PEM encoded key using environment variable.
The App is configured using a .env
file
Locally I just export MY_ENV_VAR=$(cat my_key.pem)
, but on the server, it needs to be inside the .env
file and needs to contain the value, not a command.
I've tried
echo MY_ENV_VAR=`awk 'NF {sub(/\n/, ""); printf "%s\\n",$0;}' my_key.pem` >> .env
But the generated string was not accepted by the application I'm trying to set up, it complains that the key is not PKCS1/8 compliant.
For now, I've added the export MY_ENV_VAR=$(cat my_key.pem)
to my .profile
and I launch it manually, but I would prefer to just keep the config in the .env
.
How can I do this? I'm currently running GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)
but I am fine to switch to other shell if needs be.