Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Se hai istanze di macchine virtuali (VM) Linux in esecuzione su Google Cloud,
potresti dover condividere o limitare l'accesso degli utenti o delle applicazioni alle tue VM.
Se devi gestire l'accesso degli utenti alle tue istanze VM Linux, puoi utilizzare uno
dei seguenti metodi:
Se utilizzi un tuo servizio di directory per la gestione dell'accesso o se
non riesci a configurare OS Login, puoi gestire manualmente le chiavi SSH nei
metadati.
Rischi della gestione manuale delle chiavi
Ecco alcuni dei rischi della gestione manuale delle chiavi SSH:
Tutti gli utenti che si connettono alle VM utilizzando le chiavi SSH memorizzate nei metadati hanno l'accesso
sudo alle VM.
Devi tenere traccia delle chiavi scadute ed eliminare le chiavi per gli utenti che non devono
avere accesso alle tue VM. Ad esempio, se un membro del team lascia il progetto,
devi rimuovere manualmente le relative chiavi dai metadati, in modo che non possa continuare
ad accedere alle tue VM.
Se specifichi erroneamente gcloud CLI o le chiamate API, potresti
cancellare tutte le chiavi SSH pubbliche nel tuo progetto o nelle tue VM,
interrompendo le connessioni per i membri del progetto.
Gli utenti e i service account che hanno la possibilità di modificare i metadati del progetto
possono aggiungere chiavi SSH per tutte le VM del progetto, ad eccezione di quelle che
bloccano le chiavi SSH a livello di progetto.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 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)."]]