Reputation: 267020
I just started using gcloud, and I noticed when I create a VM or going into cloud console, my full name shows up in the console.
Is there a way to create another user with a more generic name? I don't like having my full name in all my VM's and consoles.
Do I just create another user as 'owner' or is there a best practices around this?
Upvotes: 0
Views: 1326
Reputation: 81356
When you use gcloud compute ssh [INSTANCE_NAME]
, gcloud uses your current credentials to create an SSH keypair. The project ssh metadata is then updated with this username and SSH keypair. This is what you are seeing once you connect.
You can create a new SSH keypair with any username that you want. Then you can add this keypair to the instance metadata. Then you can login using that username. This also creates a new home directory in the instance.
For these examples, let's say that you want to create a new user 'development'.
STEP 1: Create a new SSH keypair
ssh-keygen -t rsa -f keypair -C development
This will create two files:
STEP 2 (Google Cloud Console Method):
STEP 3 - Connect to the instance using SSH: Replace the IP_ADDRESS with the Compute Engine instances external IP address in the following command.
ssh -i keypair development@IP_ADDRESS
This is the correct method to support multiple users connecting to the same Compute Engine instance. Each user has their own keypair and their own username and home directory.
This is also the correct method to provide users with login access to an instance that do not have Google Cloud IAM permissions to the cloud account.
For advanced users, you can use the gcloud compute instances add-metadata
command to add the SSH public key to the instance.
You can also add this SSH public key to the Project Metadata which will make this keypair available on all instances within a project.
Upvotes: 2