I'm trying to set a private SSH key environment variable on Windows. The problem is the private SSH key is in a multiline textfile of the following form:
-----BEGIN RSA PRIVATE KEY-----
Line1
Line2
Line3
...
-----END RSA PRIVATE KEY-----
I've tried the following script to store the content of the text file in a variable so I can later use it to set an environment variable:
setlocal EnableDelayedExpansion
set "var="
set LF=^
rem *** Two empty lines are required for the linefeed
FOR /F "delims=" %%a in (private_key.txt) do (
set "var=!var!!LF!%%a"
)
echo !var!
setx SSH_PRIVATE_KEY !var!
This however gives me the following error:
ERROR: Invalid syntax. Default option is not allowed more than '2' time(s).
Is there another way I can define such an environment variable?
Thanks.