Use OS Login with
workforce identity federation
(Preview): Connect to VMs that have OS
Login enabled when your organization uses an external identity provider (IdP).
Before you begin
If you haven't already, set up authentication.
Authentication verifies your identity for access to Google Cloud services and APIs. To run
code or samples from a local development environment, you can authenticate to
Compute Engine by selecting one of the following options:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and
APIs, you don't need to set up authentication.
gcloud
Install the Google Cloud CLI.
After installation,
initialize the Google Cloud CLI by running the following command:
You can set up an OS Login constraint in your organization to ensure that all
new projects, and the VM instances created in these new projects, have OS Login
enabled.
When this constraint is set up, the following conditions are applied:
enable-oslogin=true is included in the project metadata for all new
projects.
Requests that set enable-oslogin to false in instance or project
metadata are rejected, for new and existing VMs and projects.
Limitations
OS Login isn't supported in the following products, features, and OS images:
Cloud Data Fusion versions 6.1.4 and earlier.
Managed Service for Apache Airflow 1.
OS Login profiles with a total size greater than 32 KiB. The OS Login profile
includes POSIX account information and SSH public keys.
Compute instance that use the following OS images:
Windows Server and SQL Server.
Fedora CoreOS. To manage instance access to compute instances created using these
images, use the Fedora CoreOS ignition system.
SLES 16. To manage instance access to compute instances created by using these
images, use the Metadata-based SSH.
Workarounds for Cloud Data Fusion and Managed Airflow
To use OS Login in organizations that use Cloud Data Fusion and
Managed Airflow, you
can enable OS Login constraint at the organization level and then selectively
disable the constraint on projects or folders for the affected
projects.
To enable the OS Login policy, you can set the OS Login constraint on
specific projects and folders by using the Google Cloud CLI. You can also
set the OS Login constraint on the entire organization by using either
the Google Cloud console or the Google Cloud CLI.
Grant instance access to users outside of your organization
By default, users outside of your organization can't set SSH keys for instances
in your organization or be granted access to instances in your organization. In
some situations, you might need to grant instance access to users who are part
of a different organization or who have a consumer Google gmail.com account.
The
roles/compute.osLoginExternalUser
IAM role lets external Google Accounts interact with the other OS Login roles
by allowing them to configure POSIX account information.
To grant roles/compute.osLoginExternalUser and other necessary OS Login
instance access roles to users outside of your organization, complete the
following steps:
In the Google Cloud console, go to the IAM & Admin page.
The user can now connect to instances
in your project that have OS Login enabled.
Manage the OS Login API
At an organization level, you can restrict access to the OS Login API by setting
Google Workspace admin controls. To configure Google Workspace admin
controls or view configuration options, see
Control who uses Google Cloud in your organization.
As a Google Workspace admin, you can also turn on or off certain features
of the OS Login API. This includes the following options:
Choose whether to include the domain suffix in usernames generated by OS
Login API. For example, in the domain example.com, the user
user@example.com will have the username user if the setting to include
domain suffix is not checked.
Decide if members of your organization can manage SSH keys using the OS
Login API.
Restrict or permit VM access to users outside of your organization.
As a Google Workspace Admin, you can use the Google Workspace Admin
SDK to audit actions performed with the OS Login API. By reviewing these events,
you can track when a user adds, deletes, or updates an SSH key, or deletes POSIX
account information.
You can retrieve OS Login API audit activity events, from the
Google Workspace Admin SDK, by calling Activities.list() with
applicationName=gcp. For more information, see
Google Cloud activity events
in the Google Workspace Admin SDK Reports API documentation.
Modify user accounts using the Directory API
OS Login uses either your Cloud Identity or
Google Workspace
user settings when connecting to an instance. If you are a Google Workspace
super admin, you can use the Directory API to complete the following tasks for
your Google Workspace or Cloud Identity user accounts:
Modify user properties such as account name and email
Add and remove SSH keys for a user
Modify POSIX account information
Change the username that the users connect to on the instance
The following examples show how to modify or remove user accounts using the
Directory API. For more information about the account properties that you can
edit, see the
Directory API reference.
Organization admins can use the
Cloud Identity Groups API to configure supplementary
Linux groups for OS Login users by creating and managing POSIX groups. OS Login
links POSIX groups with supplementary Linux groups in your organization's VMs
so that you can manage the permissions users have in your VMs.
Membership updates take effect within 10 minutes. Group changes are
reflected in all newly created VMs. POSIX group updates may take up to six hours
to propagate to all running VMs. Users may have to log out or use the newgrp
command to observe group changes.
Delete POSIX groups configurations
OS Login POSIX group support is deprecated. We recommend that you delete OS
Login POSIX groups configurations.
Optionally verify that all groups have been deleted by
listing all POSIX groups
in your organization. If all groups have been successfully deleted, the
response is empty.
Rate limits for Linux groups with OS Login
Linux groups with OS Login use
oslogin.googleapis.com/metadata_server_groups_requests quota. By default, the
quota limit is 60 requests/minute, per project for a particular region.
If you need a higher rate limit, you can
request a quota adjustment from the Quotas
page in the Google Cloud console.
Organizations that use
workforce identity federation can use
OS Login to manage access to their VMs. When workforce identity federation is
enabled for an organization, OS Login uses certificate-based authentication
instead of key-based authentication to verify user identities.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-07-17 UTC."],[],[]]