Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Compute Engine: execute a shell command inside vm directly from gcloud console

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

like image 490
Remis Haroon - رامز Avatar asked Mar 14 '23 23:03

Remis Haroon - رامز


1 Answers

You can use the --command flag for that:

gcloud compute ssh <instance> --command <command>
like image 107
Andreas Veithen Avatar answered Apr 27 '23 06:04

Andreas Veithen