Given the title I'm guessing what you're trying to do is use a compute ssh
command for https://code.visualstudio.com/docs/remote/ssh
I couldn't find a way to use this directly, but a workaround that I found is to run:
gcloud compute config-ssh --dry-run --project "Project Name"
This will produce an SSH configuration for all the instances in your project.
I was then able to add the hosts I was interested to my vscode ssh config (~/.ssh/config
by default). It'll be something like this, but I've redacted the bits related to my project.
Host INSTANCE-NAME.ZONE.PROJECT_NAME
HostName IP
IdentityFile /Users/USER/.ssh/google_compute_engine
UserKnownHostsFile=/Users/USER/.ssh/google_compute_known_hosts
HostKeyAlias=compute.ID
IdentitiesOnly=yes
CheckHostIP=no
You could also omit the --dry-run
to automatically add the entries.