SSH access is not restricted

Restrict SSH to approved management paths instead of allowing the entire internet.

Description

Allowing TCP 22 from 0.0.0.0/0 lets any IPv4 source with a route to the VM attempt an SSH sign-in.

Potential impact

An exposed SSH service can receive unwanted login attempts. Stolen credentials or a service vulnerability can put the VM at risk.

Remediation

Set up the required VPN, IAP or bastion path and strong SSH authentication. Restrict the rule to approved sources and target VMs, then check other rules and IPv6 policies. Test that sign-in works through the approved path and other paths are blocked.

Examples

Standard support for Deployment Manager has ended. Use supported tooling to select the VPC and target VMs. For a direct connection from one fixed host, replace 203.0.113.10/32 with that host’s IPv4 address using /32. For IAP TCP forwarding, use IAP’s source range, 35.235.240.0/20.

Before

yaml
resources:
  - name: firewall
    type: compute.v1.firewall
    properties:
      sourceRanges:
        - "0.0.0.0/0"
      allowed:
        - IPProtocol: tcp
          ports:
            - "22"

After

yaml
resources:
  - name: firewall
    type: compute.v1.firewall
    properties:
      sourceRanges:
        - "203.0.113.10/32"
      allowed:
        - IPProtocol: tcp
          ports:
            - "22"

References