How to make in SSH private key from one line, three lines [closed]
Solution 1:
I would personally base64-encode the key, store it, then base64 decode it when you need it.
Encode:
echo "-----BEGIN RSA PRIVATE KEY----- my_super_secret_password -----END RSA PRIVATE KEY-----" | openssl base64 | tr -d '\n'
Decode:
echo "LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLSBteV9zdXBlcl9zZWNyZXRfcGFzc3dvcmQgLS0tLS1FTkQgUlNBIFBSSVZBVEUgS0VZLS0tLS0K" | openssl base64 -A -d
Solution 2:
Something like this, quick and hacky.
echo "-----BEGIN RSA PRIVATE KEY----- my_super_secret_password -----END RSA PRIVATE KEY-----" | sed 's/\(KEY----- \)/\1\n/' | sed 's/\(-----END\)/\n\1/'