How to install and use the Cloud SDK for Ubuntu and initialise the sdk using a Google account on Ubuntu 22.04.
- Operating System : Ubuntu 22.04
- Access to a Terminal or Shell Console
- GCP account for setting up the gcloud locally
- Web browser for login
Cloud SDK Installation
01. Open a terminal
01. Install required packages
$ sudo apt-get install apt-transport-https ca-certificates gnupg
02. Add the gcloud CLI distribution URI as a package source. If your distribution supports the signed-by option, run the following command:
$ echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
03. Import the Google Cloud public key.
$ curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo tee /usr/share/keyrings/cloud.google.gpg
04. Update and install the gcloud CLI
$ sudo apt-get update && sudo apt-get install google-cloud-cli
Authenticating via Browser
$ gcloud init
08. A link will be displayed, copy it, and open it in the browser,
09. Login using your Google account that has access to GCP.
10. Accept the permission request by selecting the Allow button.
11. It will return a code after allowing the Google Cloud SDK permissions.
12. Paste the verification code on the terminal
13. If you have existing project, you can select from the list to set the project to use or you can select the option Create a new project which is on the last item of the list. In this example we will be using an existing project.
14. Next is to choose default Compute Region and Zone. Enter ‘Y’ if you want, or ‘n’ to pass.
15. Setup is now complete and you can now use the gcloud sdk to perform some commands.
16. To verify if Google Cloud SDK is installed and your account is configured, you can try the following command. It will show the list of projects with the Project ID, Project Name and Project Number.
$ gcloud projects list
Our humans need coffee too! Your support is highly appreciated, thank you!