Bitzu

Associate Cloud Engineer ยท Compute Engine: choosing, launching and scaling

OS Login

Using IAM to control SSH access (roles/compute.osLogin, osAdminLogin), enabling via metadata, 2-step verification, comparison with metadata-based SSH keys.

Key points

  • OS Login controls SSH access with IAM.
  • Turn it on with the metadata key enable-oslogin=TRUE on a project or a single VM.
  • Grant roles/compute.osLogin for normal login or roles/compute.osAdminLogin for administrator (sudo) access.
  • Add enable-oslogin-2fa=TRUE to require 2-step verification.
  • Unlike metadata-based SSH keys, access is revoked centrally by removing the IAM role.

Source: https://docs.cloud.google.com/compute/docs/oslogin/set-up-oslogin

Practice questions

Single choice

Which metadata setting enables OS Login?

  1. os-login=on
  2. enable-iam-ssh=TRUE
  3. enable-oslogin=TRUE
  4. oslogin-mode=enabled
Show answer

Answer: C. enable-oslogin=TRUE

The key is enable-oslogin with the value TRUE, set on the project or the instance. The other keys are not recognized.

Select all that apply

Which are advantages of OS Login over metadata-based SSH keys?

  1. Access is granted and revoked through IAM
  2. It can require 2-step verification
  3. You must copy a public key into each VM's metadata
  4. It works only with Windows VMs
  5. It needs no IAM role for users
Show answer

Answer: A. Access is granted and revoked through IAM, B. It can require 2-step verification

OS Login centralizes access in IAM, so revoking a role removes access, and it can enforce 2-step verification. Per-VM key files are the old approach.

True or false

True or false: granting roles/compute.osLogin gives the user sudo rights on the VM.

Show answer

Answer: False

False. osLogin gives a standard login. Sudo requires roles/compute.osAdminLogin.

Practice 8 questions on this topic in Bitzu

Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.

Download on the App StoreGet it on Google Play

More Associate Cloud Engineer topics in this module