Description
Enable OS Login in project metadata to manage SSH access to supported Linux VMs with IAM. A VM’s own enable-oslogin value takes precedence over the project default.
Potential impact
Obsolete SSH keys or local accounts can be overlooked on VMs that manage access separately.
Remediation
First grant roles/compute.osLogin for ordinary access or roles/compute.osAdminLogin for administrative access. Users also need roles/iam.serviceAccountUser on any service account attached to the VM. Set enable-oslogin = true in metadata. Check VM overrides and test a new SSH session as an approved user. VMs using OS Login ignore metadata SSH keys.
Examples
google_compute_project_metadata manages the whole project metadata map. Keep other required entries when applying the example. Manage access separately for images that do not support OS Login.
Before
resource "google_compute_project_metadata" "project_metadata" {
metadata = {
enable-oslogin = false
}
}
After
resource "google_compute_project_metadata" "project_metadata" {
metadata = {
enable-oslogin = true
}
}