This has been happening to me for weeks now and I have no idea why. I have tried making new VMs still happens, after I ssh once or twice then I can’t do it anymore. Also when I hit troubleshoot everything is ticked.
I’m new to Google Cloud and also Linux-based systems.
Basically you need to allow GCP to access your VM via Browser, just create that firewall rule, apply it for your desired subnet and you should be able to SSH into your VM via Browser.
I tried my best at following the documentation on how to set up IAP at step 5, but still no progress, and still getting the same problem. probably didn’t work because I’m new at this stuff and might have missed something.
All you have to do it’s to create a Firewall rule like in my screenshot. Make sure you select the network that your VM uses and allow inbound connections on port 22 (SSH) from 35.235.240.0/20 (Google’s CIDR block).
I’m still having issues trying to ssh into the instance after doing what you said. But the weird thing is I can still SFTP into the instance through WinSCP, I don’t know if that means something or not. I have also run troubleshooting through gc shell and comes back with no errors in the troubleshooting but if I try ssh using a shell command it says “Permission denied (publickey)”.
I have found a workaround, I am now using a client ssh program and can now connect to my VM flawlessly so it was something to do with ssh through the google clouds browser-based one.
Also what’s the best ssh client there is that I can use?