Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restricting user access for VM in gcp

Assume two users, A and B have full access to a GCP project. User A creates a VM. Once this is done , it appears user B can login into the VM and also has sudo access to the VM.

we used enable-oslogin metadata but we have issue where user a and b belong to same group, is there any other way so that i can restrict access for user B

like image 901
mo mo Avatar asked Mar 03 '20 09:03

mo mo


People also ask

What is difference between stop and suspend in GCP?

Suspending an instance differs from stopping an instance in the following ways: Suspended instances preserve the guest OS memory, device state, and application state. Google charges for the storage necessary to save instance memory. You can only suspend an instance for up to 60 days.

How do I change permissions for a service account in GCP?

Open the Service Accounts page in the GCP Console and select the required Project. Click on Create Service Account and enter a service account name and select a role with desired permissions for the service account. Note: Make a note of the email ID of the service account. Click Save.


1 Answers

As per docs you have 2 options.

  1. Managing Instance Access Using OS Login, this feature gives you more granular control over which users can connect to your instances and what level of permission they have. If you remove roles/compute.osLogin the user won't be able to access any VM in the project (docs).

  2. To grant an user access to specific instance over SSH only you can follow the below steps (docs):

  • Add that user to the project team with view access
  • Have that user generate the public SSH key using ssh-keygen and giving you that key
  • Going to the instances pane in the Compute Engine section of the Cloud Console, selecting the instance you want to grant user access
  • Click "Add metadata" and type in "sshKeys" for the key and ":" where username is the string in the user's account before the "@" and ssh key the key that the user generated in step 2.
like image 98
lukaszberwid Avatar answered Sep 18 '22 12:09

lukaszberwid