Notes taken by Horeb S

Links

πŸ”— Link to the video

Table of contents

When setting up a development environment on a cloud virtual machine, it's crucial to follow best practices for security and efficiency. This guide covers setting up a Virtual Machine (VM) on Google Cloud Platform (GCP), configuring SSH access, port forwarding, and installing tools like Jupyter and Terraform.

Create a virtual machine and generate SSH keys

Before creating a virtual machine on our GCP project, we need to generate a SSH Key, that will allow us to connect on the machine.

The SSH key pair consists of a private key that stays on your local machine and a public key that will be added to the VM. This ensures secure authentication when connecting to your cloud instance. Let's go through the steps to generate these keys.

Step 1: Generate SSH Key Pair

Open your terminal and use the ssh-keygen command to create a new SSH key pair. By default, this will generate two files in your ~/.ssh directory: id_rsa (private key) and id_rsa.pub (public key). Make sure to protect your private key and never share it with anyone.

ssh-keygen -t rsa -f ~/.ssh/KEY_FILENAME -C USERNAME

See πŸ”—here for more information about how to create a ssh.

Step 2: Go on GCP and copy the generated ssh key

Print in your terminal the public key and go on GCP, in Compute Engine parameters : Metadata > SSH KEYS > ADD SSH KEYS, and then copy the key and save. you will get a message like β€œAll instances in this project inherit these SSH keys.”, which means that any new VM instances created in this project will automatically have access using this SSH key pair, simplifying the authentication process across multiple instances.

Step 3: Create a Virtual Machine Instance

Now that we have our SSH key set up, let's create a Virtual Machine instance on GCP. Navigate to Compute Engine > VM instances and click "Create Instance". Choose your desired configuration settings, including the machine type, boot disk (Ubuntu recommended for development), and region. Make sure to set the appropriate network tags and firewall rules to control access to your instance.

<aside> πŸ’‘

For security purposes, you should restrict access to your VM by configuring appropriate firewall rules. Consider allowing only necessary ports and limiting SSH access to specific IP ranges. Additionally, make sure to choose a machine type that balances performance needs with cost efficiency.

</aside>