Skip to main content

Command Palette

Search for a command to run...

Create Firewall Rule to Enable SSH Access (Solution)

Published
1 min read
Create Firewall Rule to Enable SSH Access (Solution)
D

A passionate full-stack developer from @ePlus.DEV

Overview

  • Labs are timed and cannot be paused. The timer starts when you click Start Lab.

  • The included cloud terminal is preconfigured with the gcloud SDK.

  • Use the terminal to execute commands and then click Check my progress to verify your work.

Challenge scenario

  • Your colleague created a custom VPC network with a compute instance in that network. You have to connect to the compute instance through ssh, but you are facing an error while connecting to the instance. After investigation, you discovered an issue with the firewall. There is no firewall at this movement which allows SSH to this instance.

  • Your task is to create a firewall rule so that you can connect to the instance through ssh.

Click Check my progress to verify the objective.


Solution of Lab

curl -LO raw.githubusercontent.com/ePlus-DEV/storage/refs/heads/main/labs/create-firewall-rule-to-enable-ssh-access-solution/lab.sh
source lab.sh

Script Alternative

VPC=\((gcloud compute instances describe \)(gcloud compute instances list --format="value(name)") --zone=\((gcloud compute instances list --format="value(zone)") --format="value(networkInterfaces[0].network.basename())"); gcloud compute firewall-rules create allow-ssh --network=\)VPC --allow=tcp:22 --source-ranges=0.0.0.0/0 --target-tags=http-server # drabhishek ji ka code copy karta hu mai

Tip & Tricks

Part 24 of 50

Quick and practical tips to help users optimize tasks, improve skills, and solve common problems effectively across various areas like tech, lifestyle, productivity, and more.

Up next

Modify VM Instance for Cost Optimization (Solution)

Overview Labs are timed and cannot be paused. The timer starts when you click Start Lab. The included cloud terminal is preconfigured with the gcloud SDK. Use the terminal to execute commands and t