Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How to use to change the default login user on my Debian 12 Google Compute Engine

 
I recently set up a LAMP server using Google Compute Engine VM and it works great.

I want to know how to login to a specific user account when I use Web based SSH Shell from the VM Instance page using the gcloud command.

It logs me into the googleuseraccount by default but I need to log in to my admin user account which I have created to be the sudo default primary account.

I have a SSH key pair created for the user admin already and it works perfectly since I can hit the VM from various other external SSH clients. So it is just a google.cloud thing I assume.

I believe there is a gccloud command that may be responsible for solving this. I have this:

gcloud compute ssh --zone "us-central1-c" "instance-test" --project "project-test"

But I do not know where to find or edit this command to add something like this: "admin@instance-test". Any help is appreciated.

Solved Solved
0 2 254
1 ACCEPTED SOLUTION

Hi @BasicBlueWS

Welcome to Google Cloud Community! 

You're on the right track! You can specify the user with the gcloud compute ssh command. Here's how to achieve your goal of logging in as the admin user:

Using the --ssh-flag option is the most straightforward method to use the --ssh-flag option to pass the -l (login) flag to the underlying SSH command.

gcloud compute ssh --zone "us-central1-c" "instance-test" --project "project-test" --ssh-flag="-l admin"

Explanation to --ssh-flag="-l admin" this is the key part. It tells gcloud compute ssh to pass the -l admin argument directly to the SSH command. The -l flag is the standard SSH option for specifying the user to log in as. For your reference see the other flags here.

If you have any questions or need assistance, please reach out to our Google Cloud Support team.


Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.

View solution in original post

2 REPLIES 2

Hi @BasicBlueWS

Welcome to Google Cloud Community! 

You're on the right track! You can specify the user with the gcloud compute ssh command. Here's how to achieve your goal of logging in as the admin user:

Using the --ssh-flag option is the most straightforward method to use the --ssh-flag option to pass the -l (login) flag to the underlying SSH command.

gcloud compute ssh --zone "us-central1-c" "instance-test" --project "project-test" --ssh-flag="-l admin"

Explanation to --ssh-flag="-l admin" this is the key part. It tells gcloud compute ssh to pass the -l admin argument directly to the SSH command. The -l flag is the standard SSH option for specifying the user to log in as. For your reference see the other flags here.

If you have any questions or need assistance, please reach out to our Google Cloud Support team.


Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.

Thank you for the support. I will try this approach as soon as I figure out where the default file containing the gcloud command actually lives. Thus far I can only see a read only version from the SSH Menu and nothing in this location ~/.config/gcloud or ~/.config/gcloud/configuration on my system.