Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Wenn Linux-VM-Instanzen auf Google Cloudausgeführt werden, müssen Sie den Nutzer- oder Anwendungszugriff möglicherweise auf Ihre VMs freigeben oder einschränken.
Wenn Sie den Nutzerzugriff auf die Linux-VM-Instanzen verwalten müssen, haben Sie dazu folgende Möglichkeiten:
Informationen zum Aktivieren von OS Login finden Sie unter OS Login einrichten.
SSH-Schlüssel in Metadaten verwalten
Wenn Sie einen eigenen Verzeichnisdienst für die Zugriffsverwaltung ausführen oder aus einem anderen Grund OS Login nicht einrichten können, haben Sie die Möglichkeit, SSH-Schlüssel in Metadaten manuell zu verwalten.
Risiken der manuellen Schlüsselverwaltung
Zu den Risiken der manuellen SSH-Schlüsselverwaltung gehören:
Alle Nutzer, die über in Metadaten gespeicherte SSH-Schlüssel eine Verbindung zu VMs herstellen, haben sudo
Zugriff auf VMs.
Sie müssen abgelaufene Schlüssel im Auge behalten und Schlüssel für Nutzer löschen, die keinen Zugriff auf Ihre VMs haben sollten. Wenn beispielsweise ein Teammitglied Ihr Projekt verlässt, müssen Sie die Schlüssel manuell aus den Metadaten entfernen, damit das Teammitglied nicht mehr auf Ihre VMs zugreifen kann.
Darüber hinaus können durch Aufrufe mit falschen Angaben in der gcloud CLI oder der API alle öffentlichen SSH-Schlüssel in Ihrem Projekt oder auf Ihren VMs gelöscht werden, was zur Unterbrechung der Verbindungen Ihrer Projektmitglieder führt.
Nutzer und Dienstkonten, die Projektmetadaten ändern können, können SSH-Schlüssel für alle VMs im Projekt hinzufügen, mit Ausnahme von VMs, die SSH-Schlüssel auf Projektebene blockieren.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-08-18 (UTC)."],[[["\u003cp\u003eGoogle Cloud offers several methods to manage user access to Linux VM instances, including OS Login and managing SSH keys in metadata.\u003c/p\u003e\n"],["\u003cp\u003eOS Login is the recommended method for managing user access to Linux VMs, enabling the use of Compute Engine IAM roles and offering enhanced security features like two-factor authentication.\u003c/p\u003e\n"],["\u003cp\u003eManually managing SSH keys in metadata carries risks, such as granting all users with those keys \u003ccode\u003esudo\u003c/code\u003e access and requiring manual tracking of expired or unauthorized keys.\u003c/p\u003e\n"],["\u003cp\u003eApplication access to VM instances can be managed through the use of SSH with service accounts, complementing user access controls.\u003c/p\u003e\n"],["\u003cp\u003eCompute Engine tools can be utilized to manage connections to instances, providing an alternative to manual key management.\u003c/p\u003e\n"]]],[],null,["*** ** * ** ***\n\nIf you have Linux virtual machine (VM) instances running on Google Cloud, you\nmight need to share or restrict user or application access to your VMs.\n\n- If you need to manage user access to your Linux VM instances, you can use one\n of the following methods:\n\n - [OS Login](#oslogin)\n - [Managing SSH keys in metadata](#ssh-access)\n - [Temporarily grant a user access to an instance](/compute/docs/access/managing-access-to-resources#bind-member)\n- If you need to manage application access to your VM instances, see\n [Use SSH with service accounts](/compute/docs/tutorials/service-account-ssh).\n\n| **Note:** When a user connects to a VM, that user can use all of the IAM permissions granted to the service account attached to the VM.\n\nManaging user access\n\nOS Login\n\nIn most scenarios, we recommend using [OS Login](/compute/docs/oslogin). The OS\nLogin feature lets you use Compute Engine IAM roles to manage\nSSH access to Linux instances. You can add an extra layer of security by\n[setting up OS Login with two-factor authentication](/compute/docs/oslogin/setup-two-factor-authentication),\nand manage access at the organization level by\n[setting up organization policies](/compute/docs/oslogin/manage-oslogin-in-an-org#set-org-policy).\n\nTo learn how to enable OS Login, see\n[Set up OS Login](/compute/docs/instances/managing-instance-access).\n\nManage SSH keys in metadata\n\nIf you are running your own directory service for managing access, or are\notherwise unable to set up OS Login, you can manually manage SSH keys in\nmetadata.\n| **Note:** If you connect to Linux VMs using the Google Cloud console or the Google Cloud CLI, Compute Engine creates SSH keys on your behalf. For more information on how Compute Engine configures and stores keys, see [About SSH connections to Linux VMs](/compute/docs/instances/ssh).\n\nRisks of manual key management\n\nSome of the risks of manual SSH key management include the following:\n\n- All users who connect to VMs using SSH keys stored in metadata have `sudo` access to VMs.\n- You must keep track of expired keys and delete keys for users who shouldn't have access to your VMs. For example, if a team member leaves your project, you must manually remove their keys from metadata, so they can't continue to access your VMs.\n- Specifying your gcloud CLI or API calls incorrectly can potentially wipe out all of the public SSH keys in your project or on your VMs, which disrupts connections for your project members.\n- Users and service accounts that have the ability to modify project metadata can add SSH keys for all VMs in the project except for VMs that [block project-level SSH keys](/compute/docs/connect/restrict-ssh-keys#block-keys).\n\nIf you aren't sure that you want to manage your own keys,\n[use Compute Engine tools to connect to your instances](/compute/docs/instances/connecting-to-instance)\ninstead.\n\nWhat's next?\n\n- Learn how to [set up OS Login](/compute/docs/instances/managing-instance-access).\n- Learn how to [create SSH keys](/compute/docs/connect/create-ssh-keys).\n- Learn how to [add SSH keys to VMs](/compute/docs/connect/add-ssh-keys).\n- Learn how to [restrict SSH keys from VMs](/compute/docs/connect/restrict-ssh-keys)."]]