VM instances should block project-wide SSH keys. This prevents SSH keys defined at the project level from granting access to individual instances, reducing the risk of unintended or persistent SSH access and lateral movement if project metadata or keys are compromised.
For Ansible resources using google.cloud.gcp_compute_instance or gcp_compute_instance, ensure the metadata.block-project-ssh-keys property is defined and set to true. Resources that omit the metadata map, omit the block-project-ssh-keys key, or set it to false are flagged.
Secure configuration example for an Ansible task:
- name:Create VM with project-wide SSH keys blockedgoogle.cloud.gcp_compute_instance:name:my-instancemachine_type:e2-mediummetadata:block-project-ssh-keys:true