You received a JSON file that contained a private key of a Service Account in order to get access to several resources in a Google Cloud project.
You downloaded and installed the Cloud SDK and want to use this private key for authentication and authorization when performing gcloud commands.
What should you do?
Click on the arrows to vote for the correct answer
A. B. C. D.B.
https://cloud.google.com/sdk/docs/authorizingIn order to use the private key of a service account for authentication and authorization when performing gcloud commands, you should follow these steps:
Download and install the Cloud SDK: The Cloud SDK is a set of tools for developing and managing resources in Google Cloud Platform. You can download and install it by following the instructions on the Google Cloud SDK website.
Download the private key JSON file: The JSON file containing the private key for the service account should be provided to you. Make sure to download this file to a secure location on your local machine.
Set the environment variable GOOGLE_APPLICATION_CREDENTIALS: To authenticate using the private key, you need to tell gcloud where to find the private key file. You can do this by setting the environment variable GOOGLE_APPLICATION_CREDENTIALS to the path of the private key file. The exact command to set this environment variable depends on your operating system:
On Linux and macOS:
javascriptexport GOOGLE_APPLICATION_CREDENTIALS="/path/to/keyfile.json"
On Windows:
swiftset GOOGLE_APPLICATION_CREDENTIALS="C:\path\to\keyfile.json"
gcloud auth activate-service-account
followed by the email address of the service account and the path to the private key file. For example:cssgcloud auth activate-service-account --key-file=/path/to/keyfile.json my-service-account@example-project.iam.gserviceaccount.com
This command sets the default authentication information for gcloud to use the specified service account.
So, the correct answer to the exam question is B. Use the command gcloud auth activate-service-account
and point it to the private key.