I'm very new to Ubuntu and developing a project based on firebase firestore database. Trying to run services on ubuntu server 22.04. I can connect firestore database (in windows I can do this by using environment variables also) with a private key file and I want to keep this file secret. To achieve this, created a file with secret and referenced it in my service config file like this.
[Unit]
Description=myservice
[Service]
Type=simple
Restart=always
RestartSec=5sec
EnvironmetnFile=/etc/mysecrets/mysecret
[Install]
WantedBy=multi-user.target
It's working for small variables like
MYSECRET=111111
But not working a file like the following
MYSECRET= {
"type": "service_account",
"project_id": "my-project-id",
"private_key_id": "1234567890abcdef",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDzq3MW0BWT4skj\n6pSG0ZXl...U6XyUrhRz\n-----END PRIVATE KEY-----\n",
"client_email": "[email protected]",
"client_id": "1234567890abcdef",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/my-project-id%40my-project-id.iam.gserviceaccount.com"
}
private_key will be 1700+ chacter long with \n
characters.
How can I create a secure secret file with such a big information in Ubuntu server? Any idea?
PS: This is not a real or valid private key file