Friday, August 19, 2022

gcloud: connect to the vm using ssh

 By default, you can connect using gcloud commands.

It will generate the ssh_key at runtime, if not there, to connect the machine.


Displayed in the browser.




gcloud compute ssh --zone "us-central1-c" "instance-name"  --project "longrunning-gcp-v2"


To connect to a specific user:


gcloud compute ssh --zone "us-central1-c" username@instance-name  --project "longrunning-gcp-v2"


To generate ssh but not connect now:

gcloud compute ssh --zone "us-central1-c" username@instance-name  --project "longrunning-gcp-v2" --dry-run


No comments:

Post a Comment