1

I would like to use gcloud compute ssh with portforwarding options in windows. When I executed following command in "Google Cloud SDK Shell" shortcut on desktop, it worked.

Welcome to the Google Cloud CLI! Run "gcloud -h" to get the list of available commands.
---

C:\Program Files (x86)\Google\Cloud SDK>gcloud compute ssh instance-name --tunnel-through-iap -- -L xxxx:localhost:vvvv
C:\Program Files (x86)\Google\Cloud SDK>

But when I executed same command in powershell, it failed.

PS C:\Users\xxxx> gcloud compute ssh instance-name --tunnel-through-iap -- -L  xxxx:localhost:vvvv
ERROR: (gcloud.compute.ssh) unrecognized arguments:
  -L
  xxxx:localhost:vvvv
  To search the help text of gcloud commands, run:
  gcloud help -- SEARCH_TERMS

How can I pass SSH args to gcloud command in powershell? I could not use past command history in "Google Cloud SDK Shell" shortcut, so I would like to use powershell (in which I can use past command history). Thanks.

ryamy
  • 31
  • 3
  • You should add gcloud cli to your PATH env variables. https://stackoverflow.com/questions/31037279/gcloud-command-not-found-while-installing-google-cloud-sdk – GeralexGR Apr 06 '22 at 07:23
  • Thanks, when I executed commands without SSH args(`-- -L xxxx:localhost:vvvv`), it works. – ryamy Apr 06 '22 at 12:08

1 Answers1

2

I should quote 2 dashes as '--' when I execute commands in powershell. Following command works in powershell according to link.

gcloud compute ssh instance-name --tunnel-through-iap '--' -L  xxxx:localhost:vvvv
ryamy
  • 31
  • 3