Data Science and Data Engineering Blog


“It always seems impossible until it’s done.”


Instruction on How to Set Up Remote Access to GCP using Ubuntu

This guide assumes that you’ve already set up your environment with VirtualBox/Ubuntu and Virtual Studio Code. If you need information on how to set up VM Ubuntu and Virtual Studio Code please read this post. Following these instructions, you will be able to set up a connection from VirtualBox/Ubuntu to Google Cloud Platform and use Virtual Studio Code to interact with GCP services.

Google offers $300 free credit that can be used with most of the GCP services. However, some services have a free usage limit. For example, the Compute Engine service allows you to create one F1-micro instance per month, which is a virtual machine that can run in different OS types based on your choice (Ubuntu, CentOS, Windows Server). Cloud Storage provides 5GB object storage for free per month. To get $300 credit you just need to create an account here ( and provide your credit card, don’t worry Google will not change after your credit or trial period ends without your permission.

Install gcloud SDK in Ubuntu instance

To connect your GCP account with your Ubuntu instance we would need to install Cloud SDK. Gcloud command tool enables you to work on the command line to orchestrate and manage resources in your Google Cloud Platform. For example, you can create Compute Engine Virtual Machine(VM) instance, or create buckets in the Cloud Storage and upload local files.

This line will add the Cloud SDK distribution URI as a package source:

echo "deb [signed-by=/usr/share/keyrings/] cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list

Before proceed we need to make sure that apt-transport-https installed. this package enables transport for downloading via HTTPS.

sudo apt-get install apt-transport-https ca-certificates gnupg

Now we can import the Google Cloud public key, but before we will install curl. Curl is a command line tool that allows transfer of data from URLs.

sudo apt install curl
curl | sudo apt-key --keyring /usr/share/keyrings/ add -

Update and install the Cloud SDK.

sudo apt-get update && sudo apt-get install google-cloud-sdk

Run gcloud init to get started.

gcloud init

Then the prompt requires login, please click the link after Go to the following link in your browser: and copy&paste the link in the browser, finish the login using your Gmail account.

After login, please copy verification the from the browser and paste it in the terminal, press enter. Then you’ll see you are logged in as: [].

Then you need to choose one project to use. If you have created a new project resource in the previous step, please use that project, otherwise, you could choose the first project, which is the default one when you initially join the Google Cloud Platform. This project could be switched later, so don’t worry if you’re not sure about which project to use. Now we can list all available projects.

gcloud projects list

Now you can directly connect with GCP Shell using the following command.

gcloud beta cloud-shell ssh

It will execute SSH keygen to create the public SSH key and the private SSH key file for gcloud. It will also push your public key to Cloud Shell.

About The Author

Scroll to Top