MEDIUM
Source
Trivy/CSPM
CSPM ID
os-login-enabled
ID
AVD-GCP-0042

OS Login should be enabled at project level

OS Login automatically revokes the relevant SSH keys when an IAM user has their access revoked.

Impact

Access via SSH key cannot be revoked automatically when an IAM user is removed.

Follow the appropriate remediation steps below to resolve the issue.

  1. Log into the Google Cloud Platform Console.

  2. Scroll down the left navigation panel and choose the “Compute Engine” to select the “VM Instances” option. Step

  3. On the “VM Instances” page, select the VM instance which needs to be verified. Step

  4. On the “VM instance details” page, scroll down and check is there is any cutom metadata for “OS login” is enabled or not for the project.Step

  5. Repeat steps number 2 - 4 to verify other VM instances in the network.

  6. Navigate to “Compute Engine”, choose the “VM instances” and select the “VM instance” which needs to enabled “Os login” for the project.Step

  7. On the “VM instance details” page, select the “Edit” button at the top.Step

  8. On the “VM instance details - Edit page”, scroll down the page and under “Custom metadata” add the key as “enable-oslogin” and value as “TRUE.”Step

  9. Click on the “Save” button to make the changes.Step

  10. Navigate to “Metadata” under the “Compute Engine” to add a project-wide metadata. Click on the “Edit” button at the top and add an entry similar to the step 8 for the key and the value and click on the “Save” button to make the changes.Step

  11. Repeat steps number 6 - 10 to set “enable-oslogin” in project-wide metadata so that it applies to all of the instances in the project.

Enable OS Login at project level

1
2
3
4
5
6
 resource "google_compute_project_metadata" "default" {
   metadata = {
     enable-oslogin = true
   }
 }