Description
OS Login manages SSH access to supported Linux VMs through IAM. When it is off, the VM uses its other configured authentication methods, such as metadata SSH keys.
Potential impact
Keys left in project or instance metadata can keep working after a user no longer needs access.
Remediation
Confirm that the OS and guest environment support OS Login. Grant the required login roles to users and automation and, if the VM has a service account, permission to use it. Set enable-oslogin: "TRUE" and test a new SSH connection and the required administrative tasks. Metadata SSH keys no longer apply.
Examples
The examples show metadata for creating a VM. Supply the name, project, machine type, disk and service account credentials. Restrict firewall access and management paths separately.
Before
- name: oslogin-disabled
google.cloud.gcp_compute_instance:
metadata:
enable-oslogin: "FALSE"
zone: us-central1-a
auth_kind: serviceaccount
After
- name: oslogin-enabled
google.cloud.gcp_compute_instance:
metadata:
enable-oslogin: "TRUE"
zone: us-central1-a
auth_kind: serviceaccount
In google.cloud 1.14.0, gcp_compute_instance does not update metadata on an existing VM. Apply that change using the Google Cloud console, gcloud or the API.