Connection via Cloud Identity-Aware Proxy Failed

Solution 1:

If the allowed Ingress for tcp:22, included your source/s IP then there is no issue with the GCP firewall and my suggestion is to do the following steps and established a serial connection to your VM and after that will be able to check the SSH service is up and in the listening mode or even check for any firewall blocking inside your VM.

  1. Go to the VM instances page in Google Cloud Platform console.
  2. Click on the instance for which you want to add a startup script.
  3. Click the Edit button at the top of the page.
  4. Click on 'Enable connecting to serial ports'
  5. Under Custom metadata, click Add item.
  6. Set 'Key' to 'startup-script' and set 'Value' to this script:

#! /bin/bash

useradd -G sudo USERNAME

echo 'USERNAME:PASSWORD' | chpasswd

NOTE: Change the value of USERNAME & PASSWORD to the username and password of your choice.

  1. Click Save and then click RESET on the top of the page. You might need to wait for some time for the instance to reboot.
  2. Click on 'Connect to serial port' in the page.
  3. In the new window, you might need to wait a bit and press on Enter of your keyboard once; then, you should see the login prompt.
  4. Login using the USERNAME and PASSWORD you provided.