SSH keys stored and managed in a project’s metadata can be used to access GCP VM instances. By default, GCP automatically deploys project-level SSH keys to VM instances.
Project-level SSH keys can lead to unauthorized access because:
There is a risk if you answered yes to any of those questions.
metadata.block-project-ssh-keys argument to true
resource "google_compute_instance" "example" { # Sensitive, because metadata.block-project-ssh-keys is not set to true
name = "example"
machine_type = "e2-micro"
zone = "us-central1-a"
network_interface {
network = "default"
access_config {
}
}
}
resource "google_compute_instance" "example" {
name = "example"
machine_type = "e2-micro"
zone = "us-central1-a"
metadata = {
block-project-ssh-keys = true
}
network_interface {
network = "default"
access_config {
}
}
}