Ensure that SSH access is restricted from the internet

Ensure that SSH access is restricted from the internet

Description: 

GCP Firewall Rules are specific to a VPC Network. Each rule either allows or denies traffic when its conditions are met. Its conditions allow you to specify the type of traffic, such as ports and protocols, and the source or destination of the traffic, including IP addresses, subnets, and instances. Firewall rules are defined at the VPC network level, and are specific to the network in which they are defined. The rules themselves cannot be shared among networks. Firewall rules only support IPv4 traffic. When specifying a source for an ingress rule or a destination for an egress rule by address, you can only use an IPv4 address or IPv4 block in CIDR notation. Generic (0.0.0.0/0) incoming traffic from internet to VPC or VM instance using SSH on Port 22 can be avoided.

Firewall rules that allow any IP address to connect to SSH ports may expose your SSH services to attackers.

The SSH service ports are:

  • SCTP - 22

  • TCP - 22



Solution: 

  1. Go to the firewall rules page. 

  2. Click EDIT.

  3. Delete 0.0.0.0/0.

  4. Add specific IP addresses or IP ranges you want to allow to connect to your instance.

  5. Add specific protocols and ports you want to open on your instance.

  6. Click SAVE.

Reference: 

https://cloud.google.com/vpc/docs/firewalls#default_firewall_rules