1

gcloud compute config-ssh works fine for listing all my VMs into the ssh config file, but I am not able to use this config file when the access from the external IP has been blocked due to firewall or other security reasons.

Is there any way to populate the config file with all internal IPs?

Currently I can't even list the internal IPs. The only way seems to be to edit the generated config file and change all the external IP addresses manually.

1 Answers1

1

I suspect the command assumes the use-case of gcloud running off GCP (outside of the internal network) and provides a convenience script to give domain names to otherwise unnamed public (external) IPs.

If you're using gcloud where you can access the VMs by the private (internal) IPs, you should be able to access the hosts by Google-provided internal DNS names without having to use this command.

DazWilkin
  • 32,823
  • 5
  • 47
  • 88
  • My use-case is to use the `ssh-config` file in the editors for quickly spinning up workspaces from remote servers which I work on. VSCode is able to automatically read this config and provides a clean option to setup entire remote workspace with remote debugging etc. – Shivam Khandelwal Jun 26 '21 at 06:15
  • It remains unclear how you're `ssh`'ing onto these VMs by their internal IPs but, I assume you're doing so from another VM on the same internal network(s). You could generate `ssh-config` with a script. You could use an instance's access to the metadata service. Or, since you appear to have `gcloud` installed too, you could use it to enumerate the instances. You don't need DNS names for `ssh-config` and could just use the machines' IPs. Good luck! – DazWilkin Jun 26 '21 at 18:17