Review VM access through project-wide SSH keys

Restrict project-wide keys on VMs that use metadata-based SSH authentication.

Description

Project SSH keys can apply to multiple VMs that use metadata-based authentication. A VM using OS Login does not read SSH keys from project or instance metadata.

Potential impact

An exposed project key can affect other reachable VMs that still accept it.

Remediation

Test a new connection with an approved instance key or least-privilege OS Login. To keep metadata-based SSH while blocking project keys, set VM metadata block-project-ssh-keys to the string "true". Review instance keys, local accounts and active sessions separately. Remove unused keys from project metadata.

Examples

These historical Deployment Manager excerpts show only part of the VM configuration. The first omits the blocking setting. Standard support has ended. Use a supported tool for new deployments and supply the remaining VM settings.

Before

yaml
resources:
  - name: vm
    type: compute.v1.instance
    properties:
      description: my-vm

After

yaml
resources:
  - name: vm
    type: compute.v1.instance
    properties:
      description: my-vm
      metadata:
        items:
          - key: block-project-ssh-keys
            value: "true"

References