Reputation: 3572
I am trying to automate creation of VMs in GCE.
I want to ssh into my VM and execute a command directly through the gcloud console.
> gcloud compute ssh <instance>
will open a new ssh window, instead of that, I want to execute the shell command inside VM directly from gcloud console without redirecting to a new ssh window.
Thanks in advance
Upvotes: 5
Views: 3046
Reputation: 9154
You can use the --command
flag for that:
gcloud compute ssh <instance> --command <command>
Upvotes: 9